Single page view mode in Xamarin Pdf Viewer (SfPdfViewer)

6 Jan 20233 minutes to read

The default continuous view mode of PDF Viewer allows vertical scrolling. In addition to that, PDF Viewer also provides options to view PDFs page by page with horizontal navigation support.

Single page view mode flipping

Single page view mode scrolling

Switching between view modes

The view mode can be switched by choosing the corresponding option from the menu bar that appears when the view mode button is clicked. The view mode button is available on the top toolbar.

Single page view mode

View mode options

The view mode can also be changed programmatically using the PageViewMode property of the PDF viewer. The enum PageViewMode has two constants - Continuous, PageByPage. The default value is Continuous. The below code snippet illustrates how to switch to the page by page view mode.

<syncfusion:SfPdfViewer x:Name="pdfViewerControl" PageViewMode="PageByPage" />
pdfViewerControl.PageViewMode = PageViewMode.PageByPage;

Tracking the changes in the PageViewMode property

When the PageViewMode property changes, the PageViewModeChanged event is raised. The second parameter of the event handler is of type PageViewModeChangedEventArgs which provides the details about the old and new view modes.

pdfViewerControl.PageViewModeChanged += PdfViewerControl_PageViewModeChanged1;
private void PdfViewerControl_PageViewModeChanged1(object sender, PageViewModeChangedEventArgs e)
{
    PageViewMode oldViewMode = e.PreviousPageViewMode;
    PageViewMode newViewMode = e.CurrentPageViewMode;
}

How to disable the page navigation by flipping in a single page view mode?

The page navigation by flipping the pages in a single page view mode can be enabled or disabled by setting the IsPageFlipEnabled API to true or false respectively.

NOTE

The default value of the IsPageFlipEnabled API is set to true.

//Disable the page navigation by flipping pages
pdfViewer.IsPageFlipEnabled= false;

NOTE

You can refer to our Xamarin PDF Viewer feature tour page for its groundbreaking feature representations. You can also explore our Xamarin.Forms PDF Viewer example to knows the functionalities of each feature.

How to show and hide the page navigation buttons in the page by page view mode on desktop?

By default in the Xamarin.Forms.UWP platform, buttons to navigate to the next page and the previous page in the page by page view mode will be visible. It can be shown or hidden by setting the ShowPageFlipNavigationArrows property of PDF Viewer to true and false respectively.

<syncfusion:SfPdfViewer x:Name="pdfViewerControl" ShowPageFlipNavigationArrows="False" />
pdfViewerControl.ShowPageFlipNavigationArrows = false;

NOTE

This API is only applicable for desktop device in UWP platform. Changing the value of this API does not have any effect on Android and iOS platforms.

How to retain the zoom percentage in page by page mode?

To persist the zoom percentage on every page while navigating in the page-by-page view mode, set the PersistZoomOnPageChange property to true. Its default value is false.

<syncfusion:SfPdfViewer x:Name="pdfViewerControl" PersistZoomOnPageChange="True"/>
pdfViewerControl.PersistZoomOnPageChange = true;

NOTE

This property is applicable only for the page-by-page view mode. Changing the value of this property does not have any effect on the continuous page view mode.