$pdf->AddPage(); $pdf->Bookmark('Paragraph 1.2', 1, 0, '', '', array(128,0,0)); $pdf->Cell(0, 10, 'Paragraph 1.2', 0, 1, 'L'); $pdf->AddPage(); $pdf->Bookmark('Sub-Paragraph 1.2.1', 2, 0, '', 'I', array(0,128,0)); $pdf->Cell(0, 10, 'Sub-Paragraph 1.2.1', 0, 1, 'L'); $pdf->AddPage(); $pdf->Bookmark('Paragraph 1.3', 1, 0, '', '', array(128,0,0)); $pdf->Cell(0, 10, 'Paragraph 1.3', 0, 1, 'L'); // add some pages and bookmarks for ($i = 2; $i < 12; $i++) { $pdf->AddPage(); $pdf->Bookmark('Chapter '.$i, 0, 0, '', 'B', array(0,64,128)); $pdf->Cell(0, 10, 'Chapter '.$i, 0, 1, 'L'); } // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . // add a new page for TOC $pdf->addTOCPage(); // write the TOC title and/or other elements on the TOC page $pdf->SetFont('times', 'B', 16); $pdf->MultiCell(0, 0, 'Table Of Content', 0, 'C', 0, 1, '', '', true, 0); $pdf->Ln(); $pdf->SetFont('helvetica', '', 10); // define styles for various bookmark levels $bookmark_templates = array(); /* * The key of the $bookmark_templates array represent the bookmark level (from 0 to n). * The following templates will be replaced with proper content: * #TOC_DESCRIPTION# this will be replaced with the bookmark description; * #TOC_PAGE_NUMBER# this will be replaced with page number. * * NOTES: * If you want to align the page number on the right you have to use a monospaced font like courier, otherwise you can left align using any font type. * The following is just an example, you can get various styles by combining various HTML elements. */ // A monospaced font for the page number is mandatory to get the right alignment $bookmark_templates[0] = '
#TOC_DESCRIPTION##TOC_PAGE_NUMBER#
'; $bookmark_templates[1] = '
 #TOC_DESCRIPTION##TOC_PAGE_NUMBER#
'; $bookmark_templates[2] = '
 #TOC_DESCRIPTION##TOC_PAGE_NUMBER#
'; // add other bookmark level templates here ... // add table of content at page 1 // (check the example n. 45 for a text-only TOC $pdf->addHTMLTOC(1, 'INDEX', $bookmark_templates, true, 'B', array(128,0,0)); // end of TOC page $pdf->endTOCPage(); // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . // --------------------------------------------------------- //Close and output PDF document $pdf->Output('example_059.pdf', 'D'); //============================================================+ // END OF FILE //============================================================+