Skip to main content

Adjust the Document View in PDF Viewer

  • 4 minutes to read

Browse Document Pages

Use the PdfViewer.CurrentPageNumber property to change the current page, as shown below. The PdfViewer.PageCount property returns the total number of document pages.

pdfViewer.CurrentPageNumber = 5;

The PdfViewer.CurrentPageChanged event occurs when an end user moves to another page. Handle this event to obtain the current page number and the total number of pages.

PDF Viewer provides the following ways to browse document pages.

  • Next and Previous buttons;

    pdf-viewer-1

  • The Pager used to show the current page number and the total number of pages. Type a required page number and press ENTER to go to this page.

    ChangePage

  • The Page Thumbnails panel on the Navigation pane. Click a page thumbnail to go to the required page.

    PageThumbnails

Rotate a Document

Use the PdfViewer.RotationAngle property to rotate document pages. The RotationAngle property can have one of the following values: 0, 90, 180, 270. Otherwise, an ArgumentOutOfRangeException occurs. The code sample below rotates the loaded document counter-clockwise.

private void PdfViewer_DocumentChanged(object sender, PdfDocumentChangedEventArgs e)
{
    pdfViewer.RotationAngle = 270;
}

Note

The PDF Viewer does not provide and API or User Interface features to rotate individual pages. Use PDF Document API instead.

The PDF Document API is a part of the Office File API or Universal subscription only, and is not included in the WinForms subscription. Please refer to the DevExpress Subscription page for pricing information.

Rotate a Document: Built-in UI Commands

End users can use Rotate Clockwise pdf-viewer-rotate-clockwise and Rotate Counterclockwise pdf-viewer-rotate-cuonterclockwise items from the context menu to rotate document pages. You can also use Ctrl + Shift + Add and Ctrl + Shift + Subtract shortcuts.

DocumentRotation

Zoom a Document

The following properties allow you to zoom in and out of a document.

API Description
PdfViewer.ZoomMode Specifies the zoom mode. When the property is set to PdfZoomMode.Custom, the PdfViewer.ZoomFactor property defines the document zoom factor value.
PdfViewer.MinZoomFactor Obtains minimum allowed zoom factor.
PdfViewer.MaxZoomFactor Obtains maximum allowed zoom factor.

The code sample below changes the zoom factor to 150 percent.

private void PdfViewer_DocumentChanged(object sender, PdfDocumentChangedEventArgs e)
{
    pdfViewer.ZoomMode = PdfZoomMode.Custom;
    pdfViewer.ZoomFactor = 150;
}

When the document’s zoom is changed, the PdfViewer.ZoomChanged event occurs. The event args allows you to obtain current zoom mode and zoom factor.

Zoom a Document: Built-in UI Commands

Use buttons on the Zoom ribbon group on the PDF Viewer tab to zoom a document.

pdf-viewer-zoom

You can press Ctrl+Plus and Ctrl+Minus, or hold Ctrl and rotate the mouse wheel to zoom a page.

Use Marquee Zoom Tool

The Marquee Zoom tool allows end users to zoom a particular part of the page.

Right-click the document and select the Marquee Zoom item in the context menu to activate the tool.

MarqueeZoomTool

Set PdfViewer.CursorMode property to PdfCursorMode.MarqueeZoom to activate the marquee zoom in code.

Drag a rectangle around the page area to zoom in on it. Click the area to increase the zoom level. Click while pressing the Ctrl key to decrease the zoom level.

ZoomToRectangle

Previous and Next View

Execute the PdfPreviousViewCommand or PdfNextViewCommand command to switch between recently used page display styles (that is, previous zoom factor, rotation angle, and page display mode). If the page display options were not changed, the PDF Viewer shows the previously displayed page.

Previous and Next View in the User Interface

Previous View pdf-viewer-prev-view and Next View pdf-viewer-next-view items allows you to navigate between recently used page display styles.

pdf-viewer-8

You can also use Alt+Left or Alt+Right shortcuts to go to previous views and pages. Note that the PDF Viewer shows these pages in reverse order.