HTML2PDF HTML2PDF est un convertisseur de code HTML en PDF écrit en PHP. Vous p
HTML2PDF HTML2PDF est un convertisseur de code HTML en PDF écrit en PHP. Vous pouvez télécharger le code source du logiciel à cette adresse : html2pdf.fr Installation HTML2PDF Après avoir télécharger la source, placez le plugin dans le dossier de votre choix de votre projet. Création d'un PDF <?php ob_start(); ?> <style type="text/css"> <!-- table { width: 100%; border:none; border-collapse: collapse; } th { text-align: center; border: solid 1px #eee; background: #f8f8f8; } td { text-align: center; border: solid 1px #eee; } --> </style> <table> <col style="width: 33%"> <col style="width: 33%"> <col style="width: 33%"> <tr> <th>Nom</th> <th>Prénom</th> <th>Ville</th> </tr> <tr> <td>ENGEL</td> <td>Olivier</td> <td>New York</td> </tr> <tr> <td>Batman</td> <td>Bruce</td> <td>Gotham</td> </tr> </table> <?php $content = ob_get_clean(); require_once( __DIR__ . "/html2pdf.class.php"); try { $html2pdf = new HTML2PDF("P", "A4", "fr"); $html2pdf->setDefaultFont("Arial"); $html2pdf->writeHTML($content); $html2pdf->Output("votre_pdf.pdf"); } catch(HTML2PDF_exception $e) { echo $e; exit; } ?> Création d'un PDF depuis une page externe <?php ob_start(); include( "votre_fichier_html.php" ); $content = ob_get_clean(); require_once( __DIR__ . "/html2pdf.class.php"); try { $html2pdf = new HTML2PDF("P", "A4", "fr"); // $html2pdf->setModeDebug(); $html2pdf->setDefaultFont("Arial"); $html2pdf->writeHTML($content); $html2pdf->Output("votre_pdf.pdf"); } catch(HTML2PDF_exception $e) { echo $e; exit; } ?> Créer une facture/commande en PDF Pour créer la commande suivante : <?php ob_start(); ?> <style type="text/css"> <!-- table { width: 100%; border:none; border-collapse: collapse; } th { text-align: center; border: solid 1px #eee; background: #f8f8f8; } td { text-align: center; } .dataTable td{ padding:10px 5px; background-color:#efefef; } .dataTable th{ padding:10px 5px; } --> </style> <page style="font-size: 12pt" backimg="./images/sign.png" backimgy="bottom"> <table cellspacing="0" style="width: 100%; text-align: center; font-size: 14px"> <tr> <td style="width: 25%; color: #444444;"> <img style="width: 100%;" src="./images/cssw_logo.png" alt="Logo"><br><br> COMMANDE CSSW </td> <td style="width: 75%;"> <table cellspacing="0" style="width: 100%; text-align: left; font-size: 11pt;"> <tr> <td style="width:50%;"></td> <td style="width:14%;text-align:left; ">Client</td> <td style="width:36%">M. Bruce Wayne</td> </tr> <tr> <td style="width:50%;"></td> <td style="width:14%;text-align:left; ">Adresse</td> <td style="width:36%"> Résidence Bruce Wayne<br> 1 ALLEE CHAUVE SOURIS<br> 00 000 - Gotham<br> </td> </tr> <tr> <td style="width:50%;"></td> <td style="width:14%;text-align:left; ">Mail</td> <td style="width:36%">batman@gotham.com</td> </tr> <tr> <td style="width:50%;"></td> <td style="width:14%;text-align:left; ">BatTel</td> <td style="width:36%">33 (0) 1 00 00 00 00</td> </tr> </table> <barcode type="EAN13" value="123467891245" style="margin-left:100mm;margin-top:10mm;width: 30mm; height: 12mm; font-size: 4 </td> </tr> </table> <br> <br> <table cellspacing="0" style="width: 100%; text-align: left;font-size: 10pt"> <tr> <td style="width:50%;"></td> <td style="width:50%; ">Gotam City, le 23/11/2013</td> </tr> </table> <br> <i> <b><u>Objet </u>: « Problème de costume »</b><br><br> Compte client : 004560100001<br> Référence du Dossier : 5406666<br> </i> <br> <br> Madame, Monsieur, SuperHero, Cher Client,<br> <br> <br> Voici votre commande: <br /> <br> <table class="dataTable" cellspacing="0" style="width: 100%; border: solid 1px black; background: #E7E7E7; text-align: center; font-size: 10pt;"> <tr> <th style="width: 20%">Produit</th> <th style="width: 20%">Désignation</th> <th style="width: 20%">Prix Unitaire</th> <th style="width: 20%">Quantité</th> <th style="width: 20%">Prix Net</th> </tr> </table> <table class="dataTable" cellspacing="0" style="width: 100%; border: solid 1px black; background: #E7E7E7; text-align: center; font-size: 10pt;"> <tr> <td style="width: 20%">Oreilles</td> <td style="width: 20%">Oreille pour costume</td> <td style="width: 20%; text-align:right;">1 500 €</td> <td style="width: 20%; text-align:right;">4x</td> <td style="width: 20%; text-align:right;">6 000 €</td> </tr> <tr> <td style="width: 20%">Cape</td> <td style="width: 20%">Cape pour costume</td> <td style="width: 20%; text-align:right;">100 €</td> <td style="width: 20%; text-align:right;">3x</td> <td style="width: 20%; text-align:right;">300 €</td> </tr> <tr> <th style="width: 20%;"></th> <th style="width: 20%;"></th> <th style="width: 20%;"></th> <th style="width: 20%; text-align:right;">Total</th> <th style="width: 20%; text-align:right;">6 300 €</th> </tr> </table> </page> <br /><br /><br /><br /><br /> A bientôt, <br /><br /><br /><br /> Olivier ENGEL. <?php $content = ob_get_clean(); require_once( __DIR__ . "/html2pdf.class.php"); try { $html2pdf = new HTML2PDF("P", "A4", "fr"); $html2pdf->setDefaultFont("Arial"); $html2pdf->writeHTML($content); $html2pdf->Output("votre_pdf.pdf"); } catch(HTML2PDF_exception $e) { echo $e; exit; } ?> Vous pouvez visualiser le PDF Commande PDF uploads/s3/ html2pdf.pdf
Documents similaires






-
24
-
0
-
0
Licence et utilisation
Gratuit pour un usage personnel Attribution requise- Détails
- Publié le Fev 12, 2021
- Catégorie Creative Arts / Ar...
- Langue French
- Taille du fichier 0.1380MB