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.view() method of the Viewer class. Specify the new page order in the last parameters.

The following code snippet shows how to reorder pages:

import com.groupdocs.viewer.Viewer;
import com.groupdocs.viewer.options.PdfViewOptions;
// ...

try (Viewer viewer = new Viewer("sample.docx")) {
    // Create a PDF file.
    PdfViewOptions viewOptions = new PdfViewOptions();

    // Pass page numbers in the order you want to render them.                                     
    viewer.view(viewOptions, 2, 1);
}