Click or drag to resize
Pdf Library for .NET

PdfBookmark Class

Represents a bookmark (outline entry) in a pdf document. Bookmarks appear in the navigation pane of PDF readers and let users jump to specific locations in the document.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfBookmark

Namespace: SelectPdf.Universal
Assembly: SelectPdf.HtmlToPdf.Universal (in SelectPdf.HtmlToPdf.Universal.dll) Version: 26.4
Syntax
public class PdfBookmark

The PdfBookmark type exposes the following members.

Properties
 NameDescription
Public propertyChildNodes Gets the child bookmark collection, used to create a nested (hierarchical) outline.
Public propertyColor Gets or sets the bookmark text color. Some PDF readers do not honor this property.
Public propertyDestination Gets or sets the bookmark destination. The destination describes which page to jump to, the position within that page, and the optional fit/zoom mode.
Public propertyParent Gets the parent of the current bookmark or null if the bookmark has no parent (i.e. it is at the top level of the document outline).
Public propertyStyle Gets or sets the bookmark text style (Normal, Italic, Bold, or Italic | Bold).
Public propertyText Gets or sets the bookmark text (the text shown in the PDF reader's outline pane).
Public propertyX Gets the X coordinate (in points) of the on-page destination that this bookmark jumps to. Shorthand for Destination.X. Returns 0 if no destination is set.
Public propertyY Gets the Y coordinate (in points) of the on-page destination that this bookmark jumps to. Shorthand for Destination.Y. Returns 0 if no destination is set.
Top
Methods
 NameDescription
Public methodSetDestination Changes both the destination page and the location on that page.
Public methodSetLocation Updates the on-page destination point. Does not change the destination page — use SetDestination(Int32, Single, Single) for that.
Top
Remarks
Bookmarks can be nested to form a hierarchy (e.g. chapter → section → subsection). Child bookmarks are added via the ChildNodes collection on this item.
Example
PdfDocument document = new PdfDocument();
document.AddPage();
PdfBookmark chapter = document.Bookmarks.Add("Chapter 1", 0);
chapter.Style = PdfBookmarkStyle.Bold;
PdfBookmark section = chapter.ChildNodes.Add("Section 1.1", 0);
document.Save("out.pdf");
document.Close();
See Also