Back to Devexpress

PdfViewerControl.GoToBookmark(PdfViewerBookmark) Method

wpf-devexpress-dot-xpf-dot-pdfviewer-dot-pdfviewercontrol-dot-gotobookmark-x28-devexpress-dot-pdf-dot-pdfviewerbookmark-x29.md

latest2.8 KB
Original Source

PdfViewerControl.GoToBookmark(PdfViewerBookmark) Method

Navigates to the specified bookmark.

Namespace : DevExpress.Xpf.PdfViewer

Assembly : DevExpress.Xpf.PdfViewer.v25.2.dll

NuGet Package : DevExpress.Wpf.PdfViewer

Declaration

csharp
public void GoToBookmark(
    PdfViewerBookmark bookmark
)
vb
Public Sub GoToBookmark(
    bookmark As PdfViewerBookmark
)

Parameters

NameTypeDescription
bookmarkPdfViewerBookmark

A bookmark to which the PDF Viewer should navigate.

|

Remarks

Use the Bookmarks property to obtain a list of document bookmarks.

The PdfViewerBookmarkExtensions.FindBookmark method allows you to find a bookmark that meets specified criteria. This method can be useful if you need to find a bookmark in a document with a complex bookmark tree.

Example

The code sample below navigates to a bookmark node with a specific title when the document is loaded. Call the Dispatcher.BeginInvoke method to use the GoToBookmark method in the PdfViewerControl.DocumentLoaded event handler.

csharp
private void PdfViewer_DocumentLoaded(object sender, RoutedEventArgs e) {
    foreach (var bookmarkItem in pdfViewer.Bookmarks) {
        if (bookmarkItem.Title == "Annotations")
            Dispatcher.BeginInvoke(new Action(() => pdfViewer.GoToBookmark(bookmarkItem)), DispatcherPriority.ApplicationIdle);
    }
}
vb
Private Sub PdfViewer_DocumentLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
    For Each bookmarkItem In pdfViewer.Bookmarks
        If bookmarkItem.Title = "Annotations" Then
            Dispatcher.BeginInvoke(New Action(Sub() pdfViewer.GoToBookmark(bookmarkItem)), DispatcherPriority.ApplicationIdle)
        End If
    Next bookmarkItem
End Sub

See Also

PdfViewerControl Class

PdfViewerControl Members

DevExpress.Xpf.PdfViewer Namespace