Rotate 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 →

Flip or rotate pages

To rotate a page when rendering document, use the RotatePage method of the ViewOptions class. This method has the following two parameters:

  1. page number
  2. rotation angle

The rotation angle is one of the following:

The following code snippet shows how to rotate output pages when rendering a document as PDF:

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

try (Viewer viewer = new Viewer("sample.docx")) {
    PdfViewOptions viewOptions = new PdfViewOptions();
    // Rotate the first page.
    viewOptions.rotatePage(1, Rotation.ON_90_DEGREE);

    viewer.view(viewOptions);
}

You can also view the example in our public GitHub repository.