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 →

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:

GroupDocs.Viewer renders a three-page DOCX to PDF with RotatePage(1, Rotation.On90Degree): page 1 is turned 90 degrees clockwise, pages 2 and 3 are unchanged. Below, the original page and what On90Degree, On180Degree and On270Degree do to it

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

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

using (Viewer viewer = new Viewer("sample.docx"))
{
    // Create a PDF file.
    PdfViewOptions viewOptions = new PdfViewOptions();
    // Rotate the first page.
    viewOptions.RotatePage(1, Rotation.On90Degree);
    viewer.View(viewOptions);
}
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
' ...

Module Program
    Sub Main(args As String())
        Using viewer As Viewer = New Viewer("sample.docx")
            ' Create a PDF file.
            Dim viewOptions As PdfViewOptions = New PdfViewOptions()
            ' Rotate the first page.
            viewOptions.RotatePage(1, Rotation.On90Degree)
            viewer.View(viewOptions)
        End Using
    End Sub
End Module

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

Binary file (PDF, 719 KB)

Download full output

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