跳到主要内容

TocBuildFromPr

Table of contents properties which specify whether to generate the table of contents from the outline levels or the specified styles.

Type

Object

Properties

NameTypeDescription
OutlineLvlsnumberMaximum number of levels in the table of contents.
StylesLvlsTocStyleLvl[]Style levels (for example, [{Name: "Heading 1", Lvl: 2}, {Name: "Heading 2", Lvl: 3}]). 💡 If StylesLvls.length > 0, then the OutlineLvls property will be ignored.

Example

This example adds a table of contents which is generated from 9 outline levels to the document.

// How to create a table of contents properties indicating the source from which it should be generated.

// Add a table of contents from the nine outline levels of the document.

let tocBuildFromPr = {"OutlineLvls": 9};
let tocPr = {"ShowPageNums": true, "RightAlgn": true, "LeaderType": "dot", "FormatAsLinks": true, "BuildFrom": tocBuildFromPr, "TocStyle": "standard"};
doc.AddTableOfContents(tocPr);