Click or drag to resize
Automatic Bookmarks Generation

The converter can produce bookmarks automatically in the generated PDF document for a list of specified HTML tags. The bookmarking is controlled by the PdfBookmarkOptions property and is enabled only when a list of HTML tag names is specified by the TagNames property.

For example, to enable bookmarking of the H1 and H2 tags you can use the following line of code:

pdfConverter.PdfBookmarkOptions.TagNames = new string[] { "H1", "H2" };

The tags to be bookmarked can be further filtered by CSS class name using the ClassNameFilter property. For example, to filter only the H1 and H2 tags having the CSS class bookmark, the following line of code can be added to the previous one:

pdfConverter.PdfBookmarkOptions.ClassNameFilter = "bookmark";

The ClassNameFilter property is case sensitive and the string value set for this property must textually match the class attribute of the HTML tag to be bookmarked.

The WebKit rendering engine supports an even more advanced way of identifying the elements that will generate the bookmarks. That is done using the HtmlElementSelectors property. This property specifies the CSS selectors of the HTML elements to be bookmarked. For example, the selector for all the H1 elements is "H1", the selector for all the elements with the CSS class name 'myclass' is "*.myclass" and the selector for the elements with the id 'myid' is "*#myid".