# TableOfContents Object

> A TableOfContents object defines the position and the properties of a table of contents. A table of contents can be automatically genarated from the structure levels defined for each paragraph in the document. A document can contain multiple tables of contents consisting of paragraphs with different levels. To generate a new table of contents the TableOfContentsCollection.add method can be used.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Object
- **Introduced:** 29.0
- **Path:** DS Server > Reference > JavaScript API > TableOfContents Object
- **1763 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/llms-full.txt

---

### Description

A TableOfContents object defines the position and the properties of a table of contents. A table of contents can be automatically genarated from the structure levels defined for each paragraph in the document. A document can contain multiple tables of contents consisting of paragraphs with different levels. To generate a new table of contents the TableOfContentsCollection.add method can be used.

### Syntax

```javascript
TableOfContents
```

### Examples

The following example demonstrates `TableOfContents` in a practical document-editing workflow. A TableOfContents object defines the position and the properties of a table of contents. A table of contents can be automatically genarated from the structure levels defined for each paragraph in the document. A document can contain multiple tables of contents consisting of paragraphs with different levels. To generate a new table of contents the TableOfContentsCollection.add method can be used.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

function inspectTableOfContents(tableOfContents) {
    tableOfContents.getID(
        function(result) {
            console.log("get id result:", result);
        },
        onTxError
    );
}
```

---

## In This Section

- [Javascript: TableOfContents.getHasLinks Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/gethaslinks-method/llms-full.txt): Gets value specifying whether each entry in the table of contents is a DocumentLink with a corresponding DocumentTarget.
- [Javascript: TableOfContents.getHasPageNumbers Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/gethaspagenumbers-method/llms-full.txt): Gets a value specifying whether the table of contents contains page numbers.
- [Javascript: TableOfContents.getHasRightAlignedPageNumbers Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/gethasrightalignedpagenumbers-method/llms-full.txt): Gets a value specifying whether the page numbers in the table of contents are right-aligned.
- [Javascript: TableOfContents.getHighlightColor Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/gethighlightcolor-method/llms-full.txt): Gets the highlight color for the table of contents.
- [Javascript: TableOfContents.getHighlightMode Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/gethighlightmode-method/llms-full.txt): Gets a value indicating whether the table of contents is highlighted.
- [Javascript: TableOfContents.getID Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/getid-method/llms-full.txt): Gets an identifier for a table of contents.
- [Javascript: TableOfContents.getLength Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/getlength-method/llms-full.txt): Gets the number of characters which belong to the table of contents.
- [Javascript: TableOfContents.getMaximumStructureLevel Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/getmaximumstructurelevel-method/llms-full.txt): Gets the maximum structure level for this table of contents. The table of contents contains all paragraphs with a structure level less than or equal this value. It must be between 1 and 10.
- [Javascript: TableOfContents.getMinimumStructureLevel Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/getminimumstructurelevel-method/llms-full.txt): Gets the minimum structure level for this table of contents. The table of contents contains all paragraphs with a structure level less than or equal this value. It must be between 1 and 10.
- [Javascript: TableOfContents.getName Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/getname-method/llms-full.txt): Gets a name for the table of contents.
- [Javascript: TableOfContents.getNumber Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/getnumber-method/llms-full.txt): Gets the number of the table of contents in the text. The first table of contents has the number 1. The number is defined through the textflow. A table of contents with a smaller start position has a smaller number.
- [Javascript: TableOfContents.getStart Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/getstart-method/llms-full.txt): Gets the index (one-based) of the first character which belongs to the table of contents.
- [Javascript: TableOfContents.getText Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/gettext-method/llms-full.txt): Gets the text of the table of contents.
- [Javascript: TableOfContents.getTitle Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/gettitle-method/llms-full.txt): Gets a title for the table of contents.
- [Javascript: TableOfContents.save Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/save-method/llms-full.txt): Saves the TableOfContents in a certain format and sends the result back asynchronously by calling a given callback function.
- [Javascript: TableOfContents.scrollTo Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/scrollto-method/llms-full.txt): Sets the current input position to the beginning of a table of contents and scrolls it into the visible part of the document.
- [Javascript: TableOfContents.setHasLinks Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/sethaslinks-method/llms-full.txt): Sets a value specifying whether each entry in the table of contents is a DocumentLink with a corresponding DocumentTarget.
- [Javascript: TableOfContents.setHasPageNumbers Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/sethaspagenumbers-method/llms-full.txt): Sets a value specifying whether the table of contents contains page numbers.
- [Javascript: TableOfContents.setHasRightAlignedPageNumbers Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/sethasrightalignedpagenumbers-method/llms-full.txt): Sets a value specifying whether the page numbers in the table of contents are right-aligned.
- [Javascript: TableOfContents.setHighlightColor Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/sethighlightcolor-method/llms-full.txt): Sets the highlight color for the table of contents.
- [Javascript: TableOfContents.setHighlightMode Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/sethighlightmode-method/llms-full.txt): Sets a value indicating whether the table of contents is highlighted.
- [Javascript: TableOfContents.setID Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/setid-method/llms-full.txt): Sets an identifier for the table of contents.
- [Javascript: TableOfContents.setMaximumStructureLevel Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/setmaximumstructurelevel-method/llms-full.txt): Sets the maximum structure level for this table of contents. The table of contents contains all paragraphs with a structure level less than or equal this value. It must be between 1 and 10.
- [Javascript: TableOfContents.setMinimumStructureLevel Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/setminimumstructurelevel-method/llms-full.txt): Sets the minimum structure level for this table of contents. The table of contents contains all paragraphs with a structure level less than or equal this value. It must be between 1 and 10.
- [Javascript: TableOfContents.setName Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/setname-method/llms-full.txt): Sets a name for the table of contents.
- [Javascript: TableOfContents.setTitle Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/settitle-method/llms-full.txt): Sets a title for the table of contents. An empty string indicates that the table of contents has no title.
- [Javascript: TableOfContents.update Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/update-method/llms-full.txt): Updates the content and the page numbers of the table of contents.

---

## Nearby

- **Previous:** [Javascript: TableInfo.nestedLevel Property](https://docs.textcontrol.com/ds-server/reference/javascript/tableinfo/nestedlevel-property/llms-full.txt)
- **Next:** [Javascript: TableOfContents.getHasLinks Method](https://docs.textcontrol.com/ds-server/reference/javascript/tableofcontents/gethaslinks-method/llms-full.txt)
