跳到主要内容

UpdateAllTOC

Updates all tables of contents in the current document.

Syntax

expression.UpdateAllTOC(bOnlyPageNumbers);

expression - A variable that represents a ApiDocument class.

Parameters

NameRequired/OptionalData typeDefaultDescription
bOnlyPageNumbersOptionalbooleanfalseSpecifies that only page numbers will be updated.

Returns

boolean

Example

This example updates all tables of contents in the current document.

// How to update all table of contents.

// Edit document content and update the table of contents.

let doc = Api.GetDocument();
let newDocumentStyle = doc.GetStyle("Heading 1");
let paragraph = doc.GetElement(0);
paragraph.SetStyle(newDocumentStyle);
paragraph.AddText("Heading 1");
newDocumentStyle = doc.GetStyle("Heading 2");
paragraph = Api.CreateParagraph();
paragraph.SetStyle(newDocumentStyle);
paragraph.AddText("Heading 2");
doc.Push(paragraph);
let tocPr = {"ShowPageNums": true, "RightAlgn": true, "LeaderType": "dot", "FormatAsLinks": true, "BuildFrom": {"OutlineLvls": 9}, "TocStyle": "standard"};
doc.AddTableOfContents(tocPr);
newDocumentStyle = doc.GetStyle("Heading 2");
paragraph = Api.CreateParagraph();
paragraph.SetStyle(newDocumentStyle);
paragraph.AddText("Heading 2");
doc.AddElement(3, paragraph);
doc.UpdateAllTOC(false);