How to go to destination page by using bookmarks of the PDF document in PdfViewer control?
How to go to destination page by using bookmarks of the PDF document in PdfViewer control?
At present, we do not have support for Bookmark Navigation in PDFViewer. However, the below workaround can be used to perform the navigation to that particular page using bookmarks of the PDF document.
Note: This workaround can handle only the navigation to a page. Navigation to a location/coordinates in a page is not supported.
The following code snippet explains how to perform the Bookmark navigation.
C#
/// <summary> /// Goes to the destination page when triggered /// </summary> /// <param name="sender">Event Sender</param> /// <param name="e">Contains Event data of the Item clicked</param> private void listView_ItemClick(object sender, ItemClickEventArgs e) { string clickedItem = e.ClickedItem.ToString(); // Bookmark selected from the ListView PdfLoadedBookmark bookmark = bookmarksDictionary[clickedItem]; // Destination page PdfPageBase page; // Checks the destion of the selected bookmark if (bookmark.Destination != null) { // assigns the destination page page = bookmark.Destination.Page; int pageIndex = 0; // Find the Page Number by comparing the destination page with all the pages foreach (PdfPageBase pageBase in ldoc.Pages) { // checks whether the iterated page equals the destination page if (pageBase == page) { // Goes to particular page using the Page Index pdfViewer.GotoPage(pageIndex + 1); break; } pageIndex++; } } }
Sample:
http://www.syncfusion.com/downloads/support/directtrac/140978/ze/PDFViewerWintRT_Bookmark2053798066
Steps to be followed:
1. Run the sample with the required PDF document contains Bookmarks.
2. Click the Button “Get PDF bookmarks”. It will display all the bookmarks present in the document in the List View.
3. Then Click any of the valid bookmark present and it will navigate to the destination page.