For the complete documentation index, see llms.txt. This page is also available as Markdown.

Reordering pages in a PDF document on Server/Desktop

Requirements

Packages are required for production license. Trial keys have unlimited access to all features.

Demo showcases functionality using WebViewer UI.

Package: Page ManipulationLive demo

To reorder pages in a PDF document by reversing the order of pages.

Given the copy and delete page operations described in other sections, it is easy to re-arrange and sort pages.

PDFDoc doc = new PDFDoc(filename);

int page_num = doc.GetPageCount();
for (int i=1; i<=page_num; ++i)
{
  PageIterator itr = doc.GetPageIterator(i);
  Page page = itr.Current();
  doc.PageRemove(itr);
  doc.PagePushFront(page);
}
PDFDoc doc(filename);

int page_num = doc.GetPageCount();
for (int i=1; i<=page_num; ++i)
{
  PageIterator itr = doc.GetPageIterator(i);
  Page page = itr.Current();
  doc.PageRemove(itr);
  doc.PagePushFront(page);
}
doc := NewPDFDoc(filename)

pageNum = doc.GetPageCount()
for i := 1; i < pageNum; i++ {
      itr := inDoc.GetPageIterator(i)
      page := itr.Current()
      doc.PageRemove(itr)
      doc.PagePushFront(page);
}

Merge, copy, delete, and rearrange PDF pages Full code sample which illustrates how to copy pages from one document to another, how to delete, and rearrange pages and how to use ImportPages(). Code sample is available in C++, C#, Java, Python, Go, PHP, Ruby & VB.

Last updated

Was this helpful?