(mPDF ≥ 2.0)
TOCpagebreak — Insert a table of contents in the document
Note: A new functionTOCpagebreakByArray()was added in mPDF 5.0 which is recommended as much simpler to use.
voidTOCpagebreak ([ string$font[, float$font-size[, int$indent[, mixed$paging[, mixed$links[, string$toc-orientation[, float$toc-margin-left[, float$toc-margin-right[, float$toc-margin-top[, float$toc-margin-bottom[, float$toc-margin-header[, float$toc-margin-footer[, string$toc-odd-header-name[, string$toc-even-header-name[, string$toc-odd-footer-name[, string$toc-even-footer-name[, int$toc-odd-header-value[, int$toc-even-header-value[, int$toc-odd-footer-value[, int$toc-even-footer-value[, string$toc-preHTML[, string$toc-postHTML[, string$toc-bookmarkText[, string$resetpagenum[, string$pagenumstyle[, string$suppress[, string$orientation[, float$margin-left[, float$margin-right[, float $$margin-top[, float $$margin-bottom[, float $$margin-header[, float$margin-footer[, string$odd-header-name[, string$even-header-name[, string $$odd-footer-name[, string $$even-footer-name[, mixed $$odd-header-value[, mixed$even-header-value[, mixed$odd-footer-value[, mixed $$even-footer-value[, string$name[, string$pageselector[, string$toc-pageselector[, string$sheet-size[, string$toc-sheet-size[, string$outdent[, int$toc-resetpagenum[, string$toc-pagenumstyle[, mixed$toc-suppress]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]])
Add a new page to the document, 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 theToC when it is generated.
Note: From mPDF 5.7 the layout of a table of contents can be controlled using CSS.$font,$font-size and$indent have become redundant.
Any values set for these are ignored, but they are kept as useless parameters to allow backwards compatibility.
Note: When writing aDOUBLE-SIDED document,theToC will always start on anODDpage. Therefore there is no option to specifiy the pagebreak$typeas inAddPage() -usingTOCpagebreak() will always continue the document on anODD page.
Note: Page numbering is always suppressed in theToC.
Note: TheToC is generated at the end of thedocument. Unless otherwise specified, theToC will inherit thepage margins, headers/footers and orientation of the last page written to the document.
Note: From mPDF 2.3 you can include more than oneToCin the document using the parameter$name.
Note: IfTOCpagebreak() is used at the start of a blank (ODD)page, no new page(s) will be added. This was added in mPDF 2.3 to allow aToC to be placed on the first page, or to allow aToC to follow anotherToC.In this case, any properties for the continuing document are ignored. If you define severalToCs following immediately on from one another, set the properties inthe firstToC you define.
The initial parameters specify characteristics for theToC, which isgenerated automatically at the end of the document whenOutput() is called.
From mPDF ≥ 5.7 CSS styles are used to control layout ofToCs. Any value set for this is ignored.
Set the font-family for theToC.
BLANK or omitted uses default font-family for the document.
From mPDF ≥ 5.7 CSS styles are used to control layout ofToCs. Any value set for this is ignored.
Sets the font size for theToC inpoints (pt)
BLANK or omitted or0 uses the default font-size for the document.
From mPDF ≥ 5.7 CSS styles are used to control layout ofToCs. Any value set for this is ignored.
Sets the value in millimetres to indent each level of theToCfrom the left margin.
BLANK or omitted uses a default value of 5mm.
true |1 |false |0Specify whether to show page numbers in theToC.
BLANK or omitted uses a default value oftrue.
Default:true
Values
true |1 |false |0Specify whether to generate hyperlinks in theToC.
BLANK or omitted uses a default value offalse.
Default:false
Values
This attribute specifies the orientation of theToC pages.
BLANK or omitted leaves the orientation unchanged i.e. at the end of the document(before theToC is generated)
'L'or'landscape''P' or'portrait'Set the page margins for theToC.
All values should be specified asLENGTH in millimetres.
If you are writing aDOUBLE-SIDED document, the margin values will be used forODD pages; left and right margins will be mirrored forEVEN pages.
BLANK or omitted leaves the current margin unchanged i.e. the margins current atthe end of the document.
0 (zero) will set the margin to zero.
Selects a header or footer by name to use for theToC. The header/footermust already have been defined usingDefHeaderByName(),DefFooterByName(),DefHTMLHeaderByName(),orDefHTMLFooterByName().
If you are writing aSINGLE-SIDED document, the values forODD will be used for all pages, and values forEVENwill be ignored.
BLANK or omitted leaves the header/footer unchanged. NBBLANK will not unset the header. Set$toc-$odd-header-value to-1 to turn the header off.
Note: You must add the prefixhtml_ before the name if it is a HTMLHeader.
Specify whether to show a header or footer in theToC. Theheader/footer must already have been defined usingDefHeaderByName(),DefFooterByName(),DefHTMLHeaderByName(),orDefHTMLFooterByName().
If you are writing aSINGLE-SIDED document, the values forODD will be used for all pages, and values forEVENwill be ignored.
BLANK or omitted or0 leaves the header/footer state unchanged.
Values (case-insensitive)
Specify the HTML code to appear before theToC 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
Specify the HTML code to appear after theToC 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.
Specify the text as it will appear as aBOOKMARK for theToC e.g.'Content list'.
BLANK or omitted will not create aBOOKMARK.
Specify whichToC to include at this point, if using more than oneToC in the document.$name can be anyalphanumeric characters (except just0) and is case-insensitive.
BLANK or omitted or0 uses the defaultToC.
Select a named CSS @page for the ToC.
BLANK or omitted or leaves the CSS page unchanged.
SeeUsing @page for more information
Can be specified either as:
'A5'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'
Set a negative indent for the last line of eachToC entry.
Values should beBLANKstring or any valid CSSLENGTH.
This will cause the line to extend beyond the right margin; you can prevent this by settingPADDING-RIGHT equal to this value.
Default:0
1 - ∞Sets/resets the document page number to$resetpagenum starting on theToC. (The value must be a positive integer).
BLANK or omitted or0 leaves the preceding page number sequence unchanged.
'1' |'A' |'a' |'I' |'i' | [+ any value supported for list-style-type]Sets/resets the page numbering style to use in theToC (values asfor cf.lists)
BLANK or omitted leaves the current page number style unchanged.
Values (case-sensitive)
'1''A''a''I''i'true |false |1 |0'on'will suppress document page numbers in theToC
BLANK or omitted leaves the current condition unchanged.
Values (case-insensitive)
The rest of the parameters are defined exactly as forAddPage(). Note that theseparameters 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 theToC.
Please refer toAddPage() forfurther details. Butnote there are differences in the order of the parameters especially take care with$orientation
| Version | Description |
|---|---|
| 2.0 | Function was added. |
| 2.2 | Default values for$font-size,$paging and$links were redefined. |
| 2.3 | $name attribute was added. |
| 4.3 | Parameters$pageselector,$sheet-size,$toc-pageselector and$toc-sheet-size were added |
| 5.7 | $outdent parameter added and parameters$font,$font-size and$indent redundant and ignored |
| 6.0 | Parameters added: $toc-resetpagenum,$toc-pagenumstyle and$toc-suppress |
<?php$mpdf=new\Mpdf\Mpdf();$mpdf->WriteHTML('Introduction');$mpdf->TOCpagebreak();$mpdf->TOC_Entry("Chapter 1",0);$mpdf->WriteHTML('Chapter 1 ...');$mpdf->Output();TOCpagebreak()