Back to Devexpress

Adjust the Document View

wpf-401115-controls-and-libraries-pdf-viewer-adjust-document-view.md

latest8.5 KB
Original Source

Adjust the Document View

  • Mar 24, 2025
  • 4 minutes to read

The topic consists of the following sections:

Change the Page Display

Specify the PdfViewerControl.PageLayout property to define how the PDF Viewer displays document pages. The DevExpress.Pdf.PdfPageLayout enumeration values specify the page layout mode as follows:

PdfPageLayout valuePage Display Mode
PdfPageLayout.OneColumnSingle Page View with enabled scrolling
PdfPageLayout.SinglePageSingle Page View
PdfPageLayout.TwoColumnLeftTwo Page View with enabled scrolling
PdfPageLayout.TwoColumnRightTwo Page View with enabled scrolling + shows the cover page
PdfPageLayout.TwoPageLeftTwo Page View
PdfPageLayout.TwoPageRightTwo Page View + shows the cover page

The code sample below specifies the PdfViewerControl.PageLayout property so that the PDF Viewer shows two pages at a time with enabled scrolling:

xaml
<dxpdf:PdfViewerControl x:Name="pdfViewer"
                        PageLayout="TwoColumnLeft"/>
csharp
pdfViewer.PageLayout = DevExpress.Pdf.PdfPageLayout.TwoColumnLeft;
vb
pdfViewer.PageLayout = DevExpress.Pdf.PdfPageLayout.TwoColumnLeft

The PdfViewerControl.PageLayoutChanged event occurs after the PageLayout property value has been changed.

Page Display in the User Interface

End users can select the desired page display mode from the Page Display drop-down list.

Browse Document Pages

Use the DocumentViewerControl.CurrentPageNumber property in the PdfViewerControl.DocumentLoaded handler to specify the displayed page. Otherwise, the property value is reset to 1. The DocumentViewerControl.PageCount property returns the total number of document pages.

csharp
private void PdfViewer_DocumentLoaded(object sender, RoutedEventArgs e)
{
    pdfViewer.CurrentPageNumber = 5;
}
vb
Private Sub PdfViewer_DocumentLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
    pdfViewer.CurrentPageNumber = 5
End Sub

PDF Viewer provides the following ways to browse document pages.

  • Previous and Next buttons;

  • 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.

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

Rotate a Document

Use the DocumentViewerControl.PageRotation property to specify document pages’ rotation angle.

csharp
private void PdfViewer_DocumentLoaded(object sender, RoutedEventArgs e)
{
    pdfViewer.PageRotation = Rotation.Rotate270;
}
vb
Private Sub PdfViewer_DocumentLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
    pdfViewer.PageRotation = Rotation.Rotate270
End Sub

The DocumentViewerControl.PageRotationChanged event occurs when the page rotation changes.

Rotate a Document: Built-in UI Commands

Users can use Rotate Clockwise item from the context menu to rotate document pages. You can also use the Ctrl + Shift + Add shortcut.

Note

The PDF Viewer does not provide and API or User Interface features to rotate individual pages. Use the 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 WPF subscription. Please refer to the DevExpress Subscription page for pricing information.

Zoom a Document

The DocumentViewerControl.ZoomMode property allows you to zoom in and out of a document. When the property is set to ZoomMode.Custom, the DocumentViewerControl.ZoomFactor property defines the document zoom factor value. The property’s minimum value is 0.1 (10%), the maximum value is 5 (500%).

The code sample below sets the zoom factor to 75% for a loaded document.

csharp
private void PdfViewer_DocumentLoaded(object sender, RoutedEventArgs e)
{
    pdfViewer.ZoomMode = DevExpress.Xpf.DocumentViewer.ZoomMode.Custom;
    pdfViewer.ZoomFactor = 0.75;
}
vb
Private Sub PdfViewer_DocumentLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
    pdfViewer.ZoomMode = DevExpress.Xpf.DocumentViewer.ZoomMode.Custom
    pdfViewer.ZoomFactor = 0.75
End Sub

You can also specify this property in XAML

xaml
<Window
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:dxp="http://schemas.devexpress.com/winfx/2008/xaml/printing">
      ...
      <dxp:DocumentPreviewControl ZoomFactor="0.75"/>
</Window>

Handle the DocumentViewerControl.ZoomChanged event to perform specific actions after a document’s zoom is changed.

Zoom a Document: Built-in UI Commands

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

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 users to zoom in a particular part of the page.

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

Set PdfViewerControl.CursorMode property to CursorModeType.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.

Previous and Next View

Execute the PdfPreviousViewCommand or NextViewCommand 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

The Previous view and Next view items to navigate between recently used page display styles.

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.