DEV Community

Cover image for Swap pages programmatically
Atir Tahir
Atir Tahir

Posted on

Swap pages programmatically

Let's see how we can exchange position of two pages in a single document:

string filePath = @"c:\sample.pptx";
string filePathOut = @"c:\output\result.pptx";

int pageNumber1 = 3;
int pageNumber2 = 6;
SwapOptions swapOptions = new SwapOptions(pageNumber2, pageNumber1);

using (Merger merger = new Merger(filePath))
{
    merger.SwapPages(swapOptions);
    merger.Save(filePathOut);
}
Enter fullscreen mode Exit fullscreen mode

Above code works with PPTX only? No, this .NET API supports a multitude of file formats including but not limited to:

  • Word
  • PDF
  • Spreadsheet

Perks

GroupDocs.Merger for .NET could be implemented in any new or existing .NET project (MVC/Web Forms/WPF/Desktop) without any third party tool or software dependency.

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay