Inheritance HierarchySystemObject
ExpertPdf.HtmlToPdf.PdfDocumentTableOfContents
Namespace: ExpertPdf.HtmlToPdf.PdfDocumentAssembly: ephtmltopdf (in ephtmltopdf.dll) Version: 22.0.0
Syntaxpublic class TableOfContents
Public Class TableOfContents
The TableOfContents type exposes the following members.
Constructors
Properties| | Name | Description |
|---|
 | DotLeaders |
Gets or sets whether a dotted leader joins the text of each entry to its page number. The default is True.
|
 | Entries |
Gets the entries, in the order they are listed.
|
 | EntryColor |
Gets or sets the color of the entries. The default is black.
|
 | EntryFont |
Gets or sets the font of the entries. When it is null (the default), Arial 11pt is embedded in the document.
|
 | EntrySpacing |
Gets or sets the space in points between two entries. The default is 4.
|
 | LevelIndent |
Gets or sets how far, in points, each level is indented from the one above it. The default is 18.
|
 | Title |
Gets or sets the title written above the entries. The default is "Contents"; null or empty writes no title.
|
 | TitleColor |
Gets or sets the color of the title. The default is black.
|
 | TitleFont |
Gets or sets the font of the title. When it is null (the default), Arial Bold 18pt is embedded in the document.
|
Top
Methods| | Name | Description |
|---|
 | AddEntries |
Adds an entry for each element of an element mapping result, in the order the elements appear in the document.
|
 | AddEntry |
Adds an entry that points to a place in the document.
|
 | Clear |
Removes all the entries.
|
Top
Remarks
Add the entries - the headings an HTML element mapped (AddEntries(Document, HtmlElementMappingsCollection))
or entries of your own (AddEntry(String, Int32, PdfPage, Single)) - after the content is added to the
document, then insert the table of contents where it goes. Each entry shows its text indented by its level, a dotted
leader and the number of the page it points to, and is a link to that place.
In a tagged document the table of contents is tagged as a TOC element, with the title as its Caption and one TOCI item
per entry.
ExampleDocument document = new Document();
PdfPage page = document.AddPage();
HtmlToPdfElement html = new HtmlToPdfElement("https://www.html-to-pdf.info");
html.RenderingEngine = RenderingEngine.Chromium;
html.HtmlElementsMappingOptions.HtmlElementSelectors = new string[] { "h1", "h2" };
page.AddElement(html);
TableOfContents toc = new TableOfContents();
toc.AddEntries(document, html.HtmlElementsMappingOptions.HtmlElementsMappingResult);
document.InsertTableOfContents(toc, 0);
document.Save("toc.pdf");Dim document As New Document()
Dim page As PdfPage = document.AddPage()
Dim html As New HtmlToPdfElement("https://www.html-to-pdf.info")
html.RenderingEngine = RenderingEngine.Chromium
html.HtmlElementsMappingOptions.HtmlElementSelectors = New String() {"h1", "h2"}
page.AddElement(html)
Dim toc As New TableOfContents()
toc.AddEntries(document, html.HtmlElementsMappingOptions.HtmlElementsMappingResult)
document.InsertTableOfContents(toc, 0)
document.Save("toc.pdf")
See Also