Reorder pages

GroupDocs.Viewer preserves the page order in the source document. Instead, you may reorder pages in the output PDF document.

To reorder pages, follow these steps:

  1. Instantiate the Viewer object.
  2. Create the PdfViewOptions object.
  3. Call the view method of the Viewer object. Specify the new page order in the last parameters.

The following code snippet shows how to reorder pages:

from groupdocs.viewer import Viewer
from groupdocs.viewer.options import PdfViewOptions

def reorder_pages():
    # Load document
    with Viewer("sample.docx") as viewer:
        # Create view options.
        viewOptions = PdfViewOptions("reorder_pages/reordered_pages.pdf")

        # Pass page numbers in the order you want to render them.
        viewer.view(viewOptions, [2, 1])

if __name__ == "__main__":
    reorder_pages()

sample.docx is the sample file used in this example. Click here to download it.

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.