TOC_Entry()
(mPDF ≥ 1.0)
TOC_Entry – Insert an entry for the Table of Contents
Description
void TOC_Entry ( string $content [, int $level [, string $name ]])
Insert an entry for the Table of Contents referencing the current writing position in the document.
Note: The position for the Table of Contents must be specified using TOCpagebreak() or <tocpagebreak> at some point before Output() is called.
Note: From mPDF 2.3 you can use more than one ToC in the document using the parameter $name.
Parameters
- $content
-
This parameter sets the text as it will appear in the ToC entry.
$content cannot contain any of the characters:
<
,>
,&
,'
or"
and must use the appropriate HTML entities e.g.<annotation content="This is < 40" />
It is recommended that you use
htmlspecialchars('Content', ENT_QUOTES)
for this.REQUIRED
- $level
-
Specify the level of this entry i.e. like heading1,2,3
Starts at level 0
Default:
0
- $name
-
Specify which ToC to add this entry, 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.Values (case-insensitive)
'ALL'
will add this entry to every ToC active in the document- name as string with only alphanumeric characters (case-insensitive)
Changelog
Version | Description |
---|---|
2.3 | $name attribute was added. |
Examples
<?php
$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML('Introduction');
$mpdf->TOCpagebreak();
$mpdf->TOC_Entry("Chapter 1",0);
$mpdf->WriteHTML('Chapter 1 ...');
$mpdf->Output();
Notes
Note: Since mPDF 2.0 insertTOC()
should not be called at the end of the document.
Output()
will automatically generate the ToC if it has been defined with either or
TOCpagebreak() or
<tocpagebreak>.
See Also
- TOCpagebreak() - Insert a Table of Contents in the document
- <tocpagebreak> - Insert a Table of Contents in the document
- <tocentry> - Mark a ToC entry in the document