tableOfContents
Appends an automatically generated table of contents.
Every bookmark in the document becomes one clickable row — title, dotted leader, final page number — that jumps to the bookmark's position. Page numbers are resolved with a dry-run layout pass, so forward references (the TOC usually sits before the chapters) come out correct, including the page shift the TOC itself introduces.
Only valid in a page body; headers, footers, and watermarks cannot host a TOC because they are rebuilt for every physical page.
Parameters
maxLevel
deepest bookmark level included; 0 lists chapters only, 1 adds their sections, and so on.
indentPerLevel
horizontal indent applied per bookmark level.
spacing
vertical gap between entry rows.