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)