Click or drag to resize
Pdf Library for .NET

PdfBookmarkOptions Class

Instructs the converter to automatically create pdf outline bookmarks from the web page elements matched by CssSelectors, optionally nesting them into a hierarchy. Reached through PdfBookmarkOptions.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfBookmarkOptions

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

The PdfBookmarkOptions type exposes the following members.

Constructors
 NameDescription
Public methodPdfBookmarkOptions 
Top
Properties
 NameDescription
Public propertyCode exampleCssSelectors Gets or sets the CSS selectors used to identify bookmark elements. When HierarchicalBookmarks is enabled, the selectors are interpreted as outline levels in array order: CssSelectors[0] becomes the top-level outline entries, CssSelectors[1] nests under them, and so on.
Public propertyHierarchicalBookmarks When true, bookmarks are nested in the PDF outline according to CssSelectors order — CssSelectors[0] elements become top- level entries, CssSelectors[1] elements nest under the preceding CssSelectors[0], and so on. When false (default), every matching element lands as a flat top-level entry. Out-of-order HTML (e.g. an h3 that appears before any h2) still produces a valid tree — the nested entry is clamped to one past the deepest open parent so no gaps appear.
Top
Example
HtmlToPdf converter = new HtmlToPdf();
converter.Options.PdfBookmarkOptions.CssSelectors =
    new string[] { "h1", "h2", "h3" };
converter.Options.PdfBookmarkOptions.HierarchicalBookmarks = true;
PdfDocument doc = converter.ConvertUrl("https://www.google.com");
doc.Save("out.pdf");
doc.Close();
See Also