(mPDF >= 1.0)
SetAnchor2Bookmark – Specifies whether PDF Bookmarks are created automatically from HTML anchors
void SetAnchor2Bookmark ( int $mode )
Specifies whether PDF Book marks are created from HTML anchors (e.g.
<a name="Introduction" />) .
Note: This function/method was altered in mPDF 2.2 by capitalising the first letter of the name. As function/method names in PHP have hitherto been case-insensitive, this should not cause any problems, but it is recommended where possible to use the preferred spelling.
Set the variable with one of the values.
0- does not generate a bookmark
1- generate a bookmark using the text value of the
<?php $mpdf = new \Mpdf\Mpdf(); $mpdf->SetAnchor2Bookmark(1); $mpdf->WriteHTML('<h1><a name="Section 1" />The title</h1>'); $mpdf->Output();
This will create a Bookmark in the PDF document: “Section 1”
Note: Prior to mPDF 3.0 you could specify
$mode = 2 which added
the page number to the bookmark e.g. “Introduction (p.32)”. This was removed as it did not accurately handle