Table of contents
The simplest example of a table of contents:
var docDefinition = {
content: [
{
toc: {
title: {text: 'INDEX', style: 'header'}
//textMargin: [0, 0, 0, 0],
//textStyle: {italics: true},
numberStyle: { bold: true },
}
},
{
text: 'This is a header',
style: 'header',
tocItem: true
}
]
}
If id is used in toc, the tocItem can target that id:
var docDefinition = {
content: [
{
toc: {
id: 'mainToc',
title: {text: 'INDEX', style: 'header'}
}
},
{
text: 'This is a header',
style: 'header',
tocItem: 'mainToc'
}
]
}
If multiple Table of Contents are used, tocItem can be used to place the text in the correct toc:
var docDefinition = {
content: [
{
toc: {
id: 'mainToc',
title: {text: 'INDEX', style: 'header'}
},
toc: {
id: 'subToc',
title: {text: 'SUB INDEX', style: 'header'}
}
},
{
text: 'This is a header',
style: 'header',
tocItem: ['mainToc', 'subToc']
}
]
}
ToC properties
id: string: (optional) only usable if you use multiple ToC lists to identifytitle: string | text node: (optional) title of ToC, string or text nodehideEmpty: boolean: (optional) (defaultfalse) hide ToC if is empty (Minimal pdfmake version: 0.3.3)textStyle: (optional)numberStyle: (optional)textMargin: (optional)sortBy: string: (optional)'page'(default) or'title'(Minimal pdfmake version: 0.3.3)sortLocale: string: (optional) default browser or nodejs language is used (Minimal pdfmake version: 0.3.3)
Node properties
tocItem: boolean | string:textStyle: (optional)numberStyle: (optional)textMargin: (optional)