Page Navigation in WPF Pdf Viewer

15 Nov 20222 minutes to read

PDF Viewer allows you to navigate through the pages of the PDF document using the GotoPage method. The following code example illustrates the navigation to page 2 of the PDF document.

//Load the PDF.
pdfViewer.Load("Sample.pdf");
//Navigate to page 2
pdfViewer.GotoPage(2);
'Load the PDF.
pdfViewer.Load("Sample.pdf")
'Navigate to page 2
pdfViewer.GotoPage(2)

You can now scroll to the given horizontal and vertical offset of the PDF document programmatically using the ScrollTo method of PdfViewerControl. Refer to the following code to scroll the PDF document to the horizontal and vertical offset of 160 and 400 respectively.

//Load the PDF.
pdfViewer.Load("Sample.pdf");
//Navigate to the horizontal and vertical offset of 160 and 400 respectively
pdfViewer.ScrollTo (160, 400);
'Load the PDF.
pdfViewer.Load("Sample.pdf")
'Navigate to the horizontal and vertical offset of 160 and 400 respectively
pdfViewer.ScrollTo (160, 400)

NOTE

Internally, the parameters (offset values) of this method will be multiplied by current zoom factor. So, the parameters (offset values) must be specified in terms of default zoom factor of 1, or 100% zoom.

// If the current zoom percentage is not 100, the parameter values must be divided by the zoom factor.
pdfViewer.ScrollTo (160d / ((double)pdfViewer.ZoomPercentage / 100d), 400d / ((double)pdfViewer.ZoomPercentage / 100d));

NOTE

You can refer to our WPF PDF Viewer feature tour page for its groundbreaking feature representations. You can also explore our WPF PDF Viewer example to know how to render and configure the pdfviewer.