Skip to main content

Update

Updates the table of contents.

note

This functionality is available in paid ONLYOFFICE Docs editions.

Syntax​

expression.Update(bOnlyPageNumbers);

expression - A variable that represents an ApiTableOfContents class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
bOnlyPageNumbersOptionalbooleanfalseNo description provided.

Returns​

boolean

Example​

Refresh a table of contents after the document content changes.

// Insert a table of contents built from the document headings.

// Rebuild the table of contents so it reflects the current headings and page numbers.

let doc = Api.GetDocument();
let style = doc.GetStyle("Heading 1");
let paragraph = doc.GetElement(0);
paragraph.SetStyle(style);
paragraph.AddText("Chapter 1");
let toc = doc.AddTableOfContents({"BuildFrom": {"OutlineLvls": 9}});
toc.Update();