Skip to main content

Table of Contents

The toc content element generates a table of contents from the headings in your document. It produces clickable entries with dotted leaders and page numbers, plus a navigable PDF outline (sidebar bookmarks) for PDF viewers.

Place it anywhere in your content array — before all content, after a cover page, or between sections.

Basic usage

Add { "toc": {} } to your content array. All defaults apply: H1–H3 headings are collected (default maxLevel: 3), title is "Table of Contents", and PDF outline bookmarks are enabled.

{
"document": {
"content": [
{ "toc": {} },
{ "h1": "Introduction" },
{ "p": "..." },
{ "h2": "Background" },
{ "p": "..." },
{ "h1": "Conclusion" },
{ "p": "..." }
]
}
}

The TOC renders on its own page(s) with a page break after it, followed by the document content. Each entry links to the corresponding heading — clicking it navigates to that location in the PDF.

Properties

PropertyTypeDefaultDescription
maxLevelnumber3Maximum heading level to include — H1 through HmaxLevel are captured (e.g. 2 includes H1+H2 only). Range 1–5.
titlestring"Table of Contents"Title text displayed above the entries
titleStylestring"h1"Named style applied to the title
stylestringNamed style applied to each entry paragraph
outlinesbooleantrueGenerate PDF outline (sidebar bookmarks)

After a cover page

Place the TOC after introductory content using a page break:

{
"document": {
"content": [
{ "p": "Annual Report 2026", "style": "coverTitle" },
{ "p": "Confidential", "style": "coverMeta" },
{ "break": "page" },

{ "toc": { "title": "Contents", "style": "tocEntry" } },

{ "h1": "Executive Summary" },
{ "p": "..." },
{ "h1": "Financial Overview" },
{ "p": "..." }
]
}
}

This produces: page 1 = cover, page 2 = table of contents, page 3+ = document body.

Filtering heading levels

Control how deep the TOC goes using the maxLevel property — H1 through HmaxLevel are captured as a contiguous range:

{ "toc": { "maxLevel": 2 } }

This includes only H1 and H2 headings, skipping H3–H5. Useful for long documents where deeper headings would make the TOC too verbose. The Word equivalent is the TOC \o "1-N" field switch — a single max rather than an explicit list.

Styling

Apply named styles to the TOC title and entries:

{
"document": {
"styles": {
"tocTitle": { "fontSize": 20, "bold": true, "fontColor": "#1B3A5C" },
"tocEntry": { "fontSize": 10, "fontColor": "#333333" }
},
"content": [
{ "toc": { "titleStyle": "tocTitle", "style": "tocEntry" } },
{ "h1": "Chapter One" },
{ "p": "..." }
]
}
}

Entries are automatically indented by heading level — H1 is flush left, H2 is indented, H3 is indented further.

PDF outline bookmarks

By default, the TOC also generates a PDF outline — the clickable bookmark tree visible in the sidebar of PDF viewers (Adobe Reader, Chrome, Preview). The outline is nested: H2 entries appear as children of the preceding H1, H3 under H2, and so on.

To disable the outline and only render the visual TOC page:

{ "toc": { "outlines": false } }

Every TOC entry is a clickable link. Clicking a title or page number navigates directly to the heading in the document. This works in all major PDF viewers.

Full example

{
"document": {
"metadata": { "title": "Compliance Report" },
"pageSetup": { "margins": [60, 50, 60, 50] },
"header": {
"content": [{ "p": "Compliance Report 2026", "style": "hdr" }],
"pageNumber": { "format": "Page {current} of {total}", "style": "hdr" },
"skipPages": [1]
},
"styles": {
"hdr": { "fontSize": 8, "fontColor": "#999999" },
"tocTitle": { "fontSize": 18, "bold": true },
"tocEntry": { "fontSize": 10 },
"body": { "fontSize": 10 }
},
"content": [
{ "p": "Compliance Report", "style": "tocTitle" },
{ "break": "page" },

{ "toc": { "maxLevel": 3, "titleStyle": "tocTitle", "style": "tocEntry" } },

{ "h1": "Executive Summary" },
{ "p": "Overall compliance posture has improved year-over-year.", "style": "body" },

{ "h1": "Regulatory Framework" },
{ "h2": "Federal Requirements" },
{ "p": "All operations comply with federal guidelines.", "style": "body" },
{ "h2": "Provincial Standards" },
{ "p": "Provincial requirements met across jurisdictions.", "style": "body" },
{ "h3": "Quebec Privacy Framework" },
{ "p": "Law 25 compliance achieved.", "style": "body" },

{ "h1": "Recommendations" },
{ "p": "Accelerate remediation of outstanding findings.", "style": "body" }
]
}
}

Excluding a heading from the TOC

Set outline: false on any h1h5 content block to keep it visually intact while excluding it from both the TOC and the PDF outline tree. Useful for cover-page titles, decorative section banners, and any heading that exists only for visual hierarchy.

{ "h1": "Annual Report 2026", "style": "coverTitle", "outline": false },
{ "h2": "Confidential — Q4 2026", "style": "coverSub", "outline": false },
{ "break": "page" },

{ "toc": {} },

{ "h1": "Executive Summary" },
{ "p": "..." }

The cover-page h1 and h2 render at full size with their styling but stay out of the TOC entries and the sidebar bookmark tree. Default is true (included). The property is ignored on non-heading content shapes.

This is the same mechanism Word's TOC field uses internally (heading styles can be marked as non-TOC) — both the DOCX and PDF backends honor the flag.

Notes

  • The TOC collects top-level headings only — headings inside columns layouts are not included.
  • The TOC page always ends with a page break, so content starts on a fresh page.
  • If no headings match maxLevel, no TOC page is rendered.
  • Page numbers in the TOC account for all preceding pages (cover, TOC itself, etc.).
  • The TOC works alongside headers, footers, and page numbers — they render correctly on all pages including the TOC page.