* distributed under the LGPL License * * @package Html2pdf * @author Laurent MINGUET <*****@*****.**> * @copyright 2016 Laurent MINGUET * * isset($_GET['vuehtml']) is not mandatory * it allow to display the result in the HTML format */ use Spipu\Html2Pdf\Html2Pdf; use Spipu\Html2Pdf\Html2PdfException; require_once dirname(__FILE__) . '/../vendor/autoload.php'; try { // init Html2Pdf $html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', array(0, 0, 0, 0)); // display the full page $html2pdf->pdf->SetDisplayMode('fullpage'); // get the HTML ob_start(); include dirname(__FILE__) . '/res/about.php'; $content = ob_get_clean(); // convert $html2pdf->writeHTML($content, isset($_GET['vuehtml'])); // add the automatic index $html2pdf->createIndex('Sommaire', 30, 12, false, true, 2); // send the PDF $html2pdf->Output('about.pdf'); } catch (Html2PdfException $e) { echo $e; exit; }
intro au chapitre 3 <bookmark title="Chapitre 3.1" level="1" ></bookmark><h2>Chapitre 3.1</h2> <div class="niveau"> Contenu du chapitre 3.1 </div> <bookmark title="Chapitre 3.2" level="1" ></bookmark><h2>Chapitre 3.2</h2> <div class="niveau"> intro au chapitre 3.2 <bookmark title="Chapitre 3.2.1" level="2" ></bookmark><h3>Chapitre 3.2.1</h3> <div class="niveau"> Contenu du chapitre 3.2.1 </div> <bookmark title="Chapitre 3.2.2" level="2" ></bookmark><h3>Chapitre 3.2.2</h3> <div class="niveau"> Contenu du chapitre 3.2.2 </div> </div> </div> </page> <?php $content = ob_get_clean(); require_once dirname(__FILE__) . '/../vendor/autoload.php'; try { $html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', 0); $html2pdf->writeHTML($content, isset($_GET['vuehtml'])); $html2pdf->createIndex('Sommaire', 25, 12, false, true, 1); $html2pdf->Output('bookmark.pdf'); } catch (Html2PdfException $e) { echo $e; exit; }