mPDF Manual – What Else Can I Do

You can insert one or more tables of contents in the document using HTML or PHP code - see:

TOC_Entry() or <tocentry> can be used to mark entries for the ToC .

From mPDF >= 5.7, CSS styles can be used to control layout of the ToC.

At the end of the document, the ToC is generated, creating HTML code (internally) which looks like this:

The id is “0” for root/un-named ToC; otherwise it is lowercase of the name=”” used for the ToC

An example CSS stylesheet for this:

For additional ToCs, these will have <toc name=”“> attribute. Use the lowercase e.g. for name=”Figures”

Automatically Generated ToC entries

You can automatically generate ToC entries from h1 - h6 tags, by setting the variable h2toc.

Only the default ToC will be used if more than 1 ToCs are defined for the document.

H1 - H6 must be written with uppercase when defining the array.

Example:

NB This will ignores calls from inside ToC e.g. if <tocpagebreak toc-prehtml=”<h3>Table of Contents</h3>” and H3 is set to auto-generate a ToC entry - these will be ignored.