Reordering pages in a PDF document on Server/Desktop

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.

1PDFDoc doc = new PDFDoc(filename);
2
3int page_num = doc.GetPageCount();
4for (int i=1; i<=page_num; ++i)
5{
6 PageIterator itr = doc.GetPageIterator(i);
7 Page page = itr.Current();
8 doc.PageRemove(itr);
9 doc.PagePushFront(page);
10}

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().

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales