Table Of Content

A table of content can be added to the document by adding a toc object to the command line. For example: wkhtmltopdf toc qstring.pdf

The table of content is generated based on the H tags in the input documents. First a XML document is generated, then it is converted to HTML using XSLT.

The generated XML document can be viewed by dumping it to a file using the --dump-outline switch. For example:wkhtmltopdf --dump-outline toc.xml qstring.pdf

The XSLT document can be specified using the —xsl-style-sheet switch. For example:wkhtmltopdf toc --xsl-style-sheet my.xsl qstring.pdf

The --dump-default-toc-xsl switch can be used to dump the default XSLT style sheet to stdout. This is a good start for writing your own style sheet

wkhtmltopdf --dump-default-toc-xsl

The XML document is in the namespace ““ it has a root node called “outline” which contains a number of “item” nodes. An item can contain any number of item. These are the outline subsections to the section the item represents. A item node has the following attributes:

  • "title" the name of the section.
  • "page" the page number the section occurs on.
  • "link" a URL that links to the section.
  • "backLink" the name of the anchor the section will link back to.

The remaining TOC options only affect the default style sheet so they will not work when specifying a custom style sheet.