Click or drag to resize
Pdf Library for .NET

PdfTableOfContentsOptions Class

Controls the table of contents the html to pdf converter completes with page numbers.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfTableOfContentsOptions

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.5
Syntax
public class PdfTableOfContentsOptions

The PdfTableOfContentsOptions type exposes the following members.

Constructors
 NameDescription
Public methodPdfTableOfContentsOptions 
Top
Properties
 NameDescription
Public propertyContainerSelector Gets or sets the CSS selector of the element that holds the page's table of contents, for example "#toc". Used by FillExisting.
Public propertyHeadingSelectors Gets or sets the CSS selectors of the headings the table of contents lists, one per level: the first selector is level 1. Used by InsertHtml.
Public propertyHtmlPlacement Gets or sets where InsertHtml writes the table of contents. The default value is Start.
Public propertyIncludeDefaultCss Gets or sets whether the default stylesheet of the table of contents written by InsertHtml is added. When false the page's CSS alone styles it. The default value is true.
Public propertyLeader Gets or sets the leader drawn between an entry and its page number. The default value is Dots.
Public propertyLeaderColor Gets or sets the color of the leader. The default value is Empty, which uses the color of the page numbers.
Public propertyLeaderGap Gets or sets the space, in points, between an entry and its leader and between the leader and the page number. The default value is 3.
Public propertyLevelStyles Gets or sets the appearance of the entries of each level drawn by GeneratePages: the first style is level 1. A level beyond the array uses the last style; a property left at its default takes the level's default.
Public propertyMaxLevel Gets or sets the deepest level listed by GeneratePages and InsertHtml. The default value is 0, which lists every level.
Public propertyMode Gets or sets how the table of contents is built. The default value is None.
Public propertyNumberColumnWidth Gets or sets the width, in CSS pixels, kept free at the end of each entry written by InsertHtml, so that a long entry wraps before its page number. The default value is 40.
Public propertyNumberEntries Gets or sets whether the entries drawn by GeneratePages are numbered ("1.", "1.1.", ...). The default value is false.
Public propertyPageBackColor Gets or sets the background color of the content area of the pages drawn by GeneratePages (the whole page when the margins are 0), so they can match a page with a colored background. The default value is Empty: no background.
Public propertyPageBreak Gets or sets whether the table of contents written by InsertHtml gets a page of its own: a page break after it, or before it when it is placed at the end. No break is added after it when the content that follows already starts a new page. The default value is true.
Public propertyPageNumberColor Gets or sets the color of the page numbers. The default value is Empty, which uses the color of the entry's text.
Public propertyPageNumberFont Gets or sets the font of the page numbers. The default value is null, which draws them in Helvetica at the size of the entry's text, or in the entry's own font for GeneratePages.
Public propertyPageNumberRightInset Gets or sets the distance, in points, between the page numbers and the right edge of the table of contents. The default value is 0.
Public propertyPagePosition Gets or sets where GeneratePages inserts its pages. The default value is Start.
Public propertyPlaceholderSelector Gets or sets the CSS selector of the element the table of contents is written into when HtmlPlacement is Placeholder.
Public propertyTitle Gets or sets the title written above the table of contents by InsertHtml. Null or empty writes no title. The default value is "Contents".
Public propertyTitleAlign Gets or sets the alignment of the title drawn by GeneratePages. A left-aligned title starts at the indent of the level 1 entries. The default value is Left.
Public propertyTitleColor Gets or sets the color of the title drawn by GeneratePages. The default value is Empty, which is black.
Public propertyTitleFont Gets or sets the font of the title drawn by GeneratePages. The default value is null, which is Helvetica Bold 18.
Public propertyTitleSpacingAfter Gets or sets the space, in points, between the title and the first entry drawn by GeneratePages. The default value is 12.
Public propertyTitleSpacingBefore Gets or sets the space, in points, above the title drawn by GeneratePages, from the top of the content area. The default value is 0.
Top
Remarks

With Mode set to FillExisting, the page's own table of contents - the element matched by ContainerSelector - is completed: every internal link inside it (<a href="#id">) gets a leader and the number of the pdf page its target is on. The number is drawn at the end of the line where the link's text ends, right-aligned to the container's right edge, so the table of contents keeps the look the page gives it.

With InsertHtml, the table of contents is written into the page first, from the elements matched by HeadingSelectors (the first selector is level 1, the second level 2, and so on): a <nav class="selectpdf-toc"> holding an optional <h2 class="selectpdf-toc-title"> and nested <ol> lists whose items have the classes selectpdf-toc-entry and selectpdf-toc-level-N and hold a link to their heading. A heading without an id is given one. The page's CSS styles it; a small default stylesheet, placed before the page's own styles, removes the list markers and indents the levels.

With GeneratePages, the table of contents is drawn on pages inserted into the pdf document (PagePosition), with the page size, margins, header and footer of the converted pages: the title, then one entry per heading, each a link to its heading, with a leader and its page number. Its appearance comes from TitleFont, TitleColor, TitleAlign, TitleSpacingAfter, LevelStyles and the page number and leader settings. The page numbers count the inserted pages.

The numbers are the page numbers the document shows: they start at the FirstPageNumber of the displayed footer (or of the displayed header when there is no footer). A link whose target is not in the document gets no number. The leaders and numbers are decorative in a tagged document (the links already carry the entries). JavaScript must be enabled.

See Also