Reorder pages

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Viewer MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-viewer -- dnx GroupDocs.Viewer.Mcp --yes
Folders, licensing and more →

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:

using GroupDocs.Viewer.Options;
using GroupDocs.Viewer;
// ...

using (Viewer viewer = new Viewer("sample.docx"))            
{     
    // Create view options.
    PdfViewOptions viewOptions = new PdfViewOptions();

    // Pass page numbers in the order you want to render them.                
    viewer.View(viewOptions, 2, 1);
}
Imports GroupDocs.Viewer.Options
Imports GroupDocs.Viewer
' ...

Module Program
    Sub Main(args As String())
        Using viewer As Viewer = New Viewer("sample.docx")
            ' Create view options.
            Dim viewOptions As PdfViewOptions = New PdfViewOptions()

            ' Pass page numbers in the order you want to render them.                
            viewer.View(viewOptions, 2, 1)
        End Using
    End Sub
End Module

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

Binary file (PDF, 199 KB)

Download full output