mPDF Manual – mPDF functions

# TOCpagebreakByArray()

(mPDF >= 5.0)

TOCpagebreakByArray — Insert a table of contents in the document using an array of parameters

void TOCpagebreakByArray ([ array $arr ]) Add a new page to the document using an array of (optional) parameters, marking the point at which a Table of Contents (ToC) will be inserted in the document at the end of writing. The numerous parameters specify both paging details for the continuing document, and for the ToC when it is generated. ## Parameters The initial parameters specify characteristics for the ToC, which is generated automatically at the end of the document when Output() is called. $paging = TRUE 1 FALSE 0

Specify whether to show page numbers in the ToC.

BLANK or omitted uses a default value of TRUE.

DEFAULT: TRUE

Values

TRUE or 1: show page numbers in the ToC.

FALSE or 0: do not show page numbers in the ToC.

 $links = TRUE 1 FALSE 0 Specify whether to generate hyperlinks in the ToC. BLANK or omitted uses a default value of FALSE. DEFAULT: FALSE Values TRUE or 1: show hyperlinks in the ToC. FALSE or 0: do not show hyperlinks in the ToC.$toc-orientation

This attribute specifies the orientation of the ToC pages.

BLANK or omitted leaves the orientation unchanged i.e. at the end of the document (before the ToC is generated)

Values (case-insensitive)

L or landscape: Landscape

P or portrait: Portrait

$toc-margin-left toc-margin-right </span>$toc-margin-top

toc-margin-bottom

</span>$toc-margin-header toc-margin-footer</span> Set the page margins for the ToC. All values should be specified as LENGTH in millimetres. If you are writing a DOUBLE-SIDED document, the margin values will be used for ODD pages; left and right margins will be mirrored for EVEN pages. BLANK or omitted leaves the current margin unchanged i.e. the margins current at the end of the document. “0” (zero) will set the margin to zero.$outdent

Set a negative indent for the last line of each ToC entry.

Values should be BLANK string or any valid CSS LENGTH.

This will cause the line to extend beyond the right margin; you can prevent this by setting PADDING-RIGHT equal to this value.

DEFAULT 0

$toc-odd-header-name toc-even-header-name</span>$

toc-odd-footer-name

</span>$toc-even-footer-name Selects a header or footer by name to use for the ToC. The header/footer must already have been defined using DefHeaderByName(), DefFooterByName(), DefHTMLHeaderByName(), or DefHTMLFooterByName(). If you are writing a SINGLE-SIDED document, the values for ODD will be used for all pages, and values for EVEN will be ignored. BLANK or omitted leaves the header/footer unchanged. NB BLANK will not unset the header. Set$toc-$odd-header-value to -1 to turn the header off.$toc-odd-header-value$toc-even-header-value toc-odd-footer-value</span>$

toc-even-footer-value</span>

Specify whether to show a header or footer in the ToC. The header/footer must already have been defined using DefHeaderByName(), DefFooterByName(), DefHTMLHeaderByName(), or DefHTMLFooterByName().

If you are writing a SINGLE-SIDED document, the values for ODD will be used for all pages, and values for EVEN will be ignored.

BLANK or omitted or 0 leaves the header/footer state unchanged.

Values (case-insensitive)

1 or on: Show the selected header/footer in the ToC.

-1 or off: Hide the selected header/footer in the ToC.

$toc-preHTML Specify the HTML code to appear before the ToC e.g. ‘<h1>Contents</h1>’. Note that in contrast with the HTML equivalent <tocpagebreak> the text does not need to use HTML-entities. BLANK or omitted will enter no text$toc-postHTML

Specify the HTML code to appear after the ToC e.g. ‘<p>Comments to go below the ToC</p>’. Note that in contrast with the HTML equivalent <tocpagebreak> the text does not need to use HTML-entities.

BLANK or omitted will enter no text.

$toc-bookmarkText Specify the text as it will appear as a BOOKMARK for the ToC e.g. ‘Content list’. BLANK or omitted will not create a BOOKMARK.$name

Specify which ToC to include at this point, if using more than one ToC in the document. $name can be any alphanumeric characters (except just “0”) and is case-insensitive. BLANK or omitted or 0 uses the default ToC.$toc-pageselector

Select a named CSS @page for the  ToC.

BLANK or omitted or leaves the CSS page unchanged.

$toc-sheet-size$sheet-size can be specified either as a pre-defined page size, or as an array of width and height in millimetres e.g. array(210,297).

DEFAULT: BLANK - makes no change to the current sheet-size

Values (case-insensitive)

A0 - A10, B0 - B10, C0 - C10

4A0, 2A0, RA0 - RA4, SRA0 - SRA4

Letter, Legal, Executive, Folio

Demy, Royal

A (Type A paperback 111x178mm)

B (Type B paperback 128x198mm)

All of the above values can be suffixed with “-L” to force a Landscape page orientation document e.g. “A4-L”

The rest of the parameters are defined exactly as for AddPageByArray(). Note that these parameters define page numbering, margins, headers/footers for the document as it continues from this point on; in the final document this will be the part of the document immediately after the ToC.

Please refer to AddPageByArray() for further details.

## Changelog

VersionDescription
5.0 Function was added.
5.7 $outdent parameter added$font, $font-size and$indent redundant

Example #1