<?php /** * Logiciel : exemple d'utilisation de HTML2PDF * * Convertisseur HTML => PDF * Distribué sous la licence LGPL. * * @author Laurent MINGUET <*****@*****.**> */ require_once dirname(__FILE__) . '/../html2pdf.class.php'; // récupération de l'html ob_start(); include dirname('__FILE__') . '/res/about.php'; $content = ob_get_clean(); // initialisation de HTML2PDF $html2pdf = new HTML2PDF('P', 'A4', 'fr', array(0, 0, 0, 0)); // affichage de la page en entier $html2pdf->pdf->SetDisplayMode('fullpage'); // conversion $html2pdf->writeHTML($content, isset($_GET['vuehtml'])); // ajout de l'index (obligatoirement en fin de génération) $html2pdf->createIndex('Sommaire', 30, 12, false, true, 2); // envoie du PDF $html2pdf->Output('about.pdf');
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_html = ob_get_clean(); // initialisation de HTML2PDF require_once dirname(__FILE__) . '/../html2pdf.class.php'; try { $html2pdf = new HTML2PDF('P', 'A4', 'fr', false, 'ISO-8859-15', array(0, 0, 0, 0)); $html2pdf->writeHTML($content_html, isset($_GET['vuehtml'])); $html2pdf->createIndex('Sommaire', 25, 12, false, true, 1); $html2pdf->Output('bookmark.pdf'); } catch (HTML2PDF_exception $e) { echo $e; }