Back to Devexpress

PdfViewerControl.Bookmarks Property

wpf-devexpress-dot-xpf-dot-pdfviewer-dot-pdfviewercontrol-bc041ef8.md

latest3.6 KB
Original Source

PdfViewerControl.Bookmarks Property

Returns a list of document bookmarks.

Namespace : DevExpress.Xpf.PdfViewer

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

NuGet Package : DevExpress.Wpf.PdfViewer

Declaration

csharp
public IReadOnlyList<PdfViewerBookmark> Bookmarks { get; }
vb
Public ReadOnly Property Bookmarks As IReadOnlyList(Of PdfViewerBookmark)

Property Value

TypeDescription
IReadOnlyList<PdfViewerBookmark>

A list of document bookmarks.

|

Remarks

Call the GoToBookmark method to navigate to a specific bookmark.

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

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

The code sample below finds a bookmark with the specified title and navigates to this bookmark when the document is loaded:

csharp
using DevExpress.Pdf;

private void PdfViewer_DocumentLoaded(object sender, RoutedEventArgs e) {
    var bookmark = pdfViewer.Bookmarks.FindBookmark(x => x.Title == "4 Notation");
    if (bookmark != null) {
        pdfViewer.GoToBookmark(bookmark);
    }

}
vb
Imports DevExpress.Pdf

Private Sub PdfViewer_DocumentLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim bookmark = pdfViewer.Bookmarks.FindBookmark(Function(x) x.Title = "4 Notation")
    If bookmark IsNot Nothing Then
        pdfViewer.GoToBookmark(bookmark)
    End If
End Sub

See Also

PdfViewerControl Class

PdfViewerControl Members

DevExpress.Xpf.PdfViewer Namespace