Back to Devexpress

PdfDocument.Bookmarks Property

officefileapi-devexpress-dot-pdf-dot-pdfdocument-f846426f.md

latest4.4 KB
Original Source

PdfDocument.Bookmarks Property

Gets or sets the bookmarks that are used to navigate from one part of a document to another.

Namespace : DevExpress.Pdf

Assembly : DevExpress.Pdf.v25.2.Core.dll

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public IList<PdfBookmark> Bookmarks { get; set; }
vb
Public Property Bookmarks As IList(Of PdfBookmark)

Property Value

TypeDescription
IList<PdfBookmark>

A list of PdfBookmark objects that are the collection of bookmarks.

|

Exceptions

TypeDescription
NullReferenceException

Occurs if the property is set to null.

|

Example

How to: Create a Bookmark that Navigates to a Specific Page

The following code snippet creates a bookmark with a destination that displays the eighth page as follows:

csharp
using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
{
    // Load a document
    pdfDocumentProcessor.LoadDocument("Demo.pdf");

    // Create a FitB destination that refers to the eighth page
    PdfFitBBoxDestination destination =
       new PdfFitBBoxDestination(pdfDocumentProcessor.Document.Pages[7]);

    // Create a bookmark
    PdfBookmark bookmark = new PdfBookmark();
    bookmark.Title = "Annotations";

    // Associate the bookmark with the created destination
    bookmark.Destination = destination;

    // Add the bookmark to the document collection
    pdfDocumentProcessor.Document.Bookmarks.Add(bookmark);

    // Save the result
    pdfDocumentProcessor.SaveDocument("out.pdf");
}
vb
Using pdfDocumentProcessor As New PdfDocumentProcessor()
  ' Load a document
  pdfDocumentProcessor.LoadDocument("Demo.pdf")

  ' Create a FitB destination that refers to the eighth page
  Dim destination As New PdfFitBBoxDestination
    (pdfDocumentProcessor.Document.Pages(1))

  ' Create a bookmark
  Dim bookmark As New PdfBookmark()
  bookmark.Title = "Annotations"

  ' Associate the bookmark with the created destination
  bookmark.Destination = destination

  ' Add a bookmark to the document collection
  pdfDocumentProcessor.Document.Bookmarks.Add(bookmark)

  ' Save the result
  pdfDocumentProcessor.SaveDocument("out.pdf")
End Using

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Bookmarks property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

pdf-document-api-bookmark-search-results-in-document/CS/Destination/Program.cs#L24

csharp
// Get bookmark list.
IList<PdfBookmark> bookmarks = documentProcessor.Document.Bookmarks;
foreach (string word in words) {

pdf-document-api-bookmark-search-results-in-document/VB/Destination/Program.vb#L20

vb
' Get bookmark list.
Dim bookmarks As System.Collections.Generic.IList(Of DevExpress.Pdf.PdfBookmark) = documentProcessor.Document.Bookmarks
For Each word As String In words

See Also

PdfDocument Class

PdfDocument Members

DevExpress.Pdf Namespace