Back to Devexpress

PdfBookmark Class

officefileapi-devexpress-dot-pdf-5674f063.md

latest3.0 KB
Original Source

PdfBookmark Class

Contains settings that are used to specify bookmarks in a document.

Namespace : DevExpress.Pdf

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

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public class PdfBookmark :
    IPdfBookmarkParent
vb
Public Class PdfBookmark
    Implements IPdfBookmarkParent

Remarks

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

Important

The bookmark hierarchy must contain only distinct instances of the PdfBookmark class. The following code snippet shows this prohibited action.

csharp
PdfBookmark bookmark = new PdfBookmark();
bookmark.Children.Add(bookmark);
vb
Dim bookmark As PdfBookmark = New PdfBookmark() 
bookmark.Children.Add(bookmark)

Example

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

Inheritance

Object PdfBookmark

See Also

PdfBookmark Members

DevExpress.Pdf Namespace