 |
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 HierarchySystemObject
SelectPdf.UniversalPdfBookmarkOptions
Namespace: SelectPdf.UniversalAssembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntaxpublic class PdfBookmarkOptions
Public Class PdfBookmarkOptions
The PdfBookmarkOptions type exposes the following members.
Constructors
Properties| | Name | Description |
|---|
  | CssSelectors |
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.
|
 | HierarchicalBookmarks |
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
ExampleHtmlToPdf 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();Dim converter As New HtmlToPdf()
converter.Options.PdfBookmarkOptions.CssSelectors =
New String() {"h1", "h2", "h3"}
converter.Options.PdfBookmarkOptions.HierarchicalBookmarks = True
Dim doc As PdfDocument = converter.ConvertUrl("https://www.google.com")
doc.Save("out.pdf")
doc.Close()
See Also