Ver Mensaje Individual
  #4 (permalink)  
Antiguo 29/07/2015, 08:56
Avatar de xfxstudios
xfxstudios
 
Fecha de Ingreso: junio-2015
Ubicación: Valencia - Venezuela
Mensajes: 2.448
Antigüedad: 8 años, 10 meses
Puntos: 263
Respuesta: Error al generar PDF con html2pdf

mira este codigo para esa libreria, por ningun lado indica que debes incluir etiquetas html, tittle, head o lo que sea:

Código PHP:
Ver original
  1. <page backtop="10mm" backbottom="10mm" backleft="20mm" backright="20mm">
  2.     <page_header>
  3.         <table style="width: 100%; border: solid 1px black;">
  4.             <tr>
  5.                 <td style="text-align: left;    width: 33%">html2pdf</td>
  6.                 <td style="text-align: center;    width: 34%">Test d'header</td>
  7.                 <td style="text-align: right;    width: 33%"><?php echo date('d/m/Y'); ?></td>
  8.             </tr>
  9.         </table>
  10.     </page_header>
  11.     <page_footer>
  12.         <table style="width: 100%; border: solid 1px black;">
  13.             <tr>
  14.                 <td style="text-align: left;    width: 50%">html2pdf.fr</td>
  15.                 <td style="text-align: right;    width: 50%">page [[page_cu]]/[[page_nb]]</td>
  16.             </tr>
  17.         </table>
  18.     </page_footer>
  19.     <span style="font-size: 20px; font-weight: bold">Démonstration des retour à la ligne automatique, ainsi que des sauts de page automatique</span><br>
  20.     <br>
  21.     <br>
  22.     <table style="width: 80%;border: solid 1px #5544DD; border-collapse: collapse" align="center">
  23.         <thead>
  24.             <tr>
  25.                 <th style="width: 30%; text-align: left; border: solid 1px #337722; background: #CCFFCC">Header 1</th>
  26.                 <th style="width: 30%; text-align: left; border: solid 1px #337722; background: #CCFFCC">Header 2</th>
  27.             </tr>
  28.         </thead>
  29.         <tbody>
  30. <?php
  31.     for ($k=0; $k<13; $k++) {
  32. ?>
  33.             <tr>
  34.                 <td style="width: 30%; text-align: left; border: solid 1px #55DD44">
  35.                     test de texte assez long pour engendrer des retours à la ligne automatique...
  36.                     a b c d e f g h i j k l m n o p q r s t u v w x y z
  37.                     a b c d e f g h i j k l m n o p q r s t u v w x y z
  38.                 </td>
  39.                 <td style="width: 70%; text-align: left; border: solid 1px #55DD44">
  40.                     test de texte assez long pour engendrer des retours à la ligne automatique...
  41.                     a b c d e f g h i j k l m n o p q r s t u v w x y z
  42.                     a b c d e f g h i j k l m n o p q r s t u v w x y z
  43.  
  44.                 </td>
  45.             </tr>
  46. <?php
  47.     }
  48. ?>
  49.         </tbody>
  50.         <tfoot>
  51.             <tr>
  52.                 <th style="width: 30%; text-align: left; border: solid 1px #337722; background: #CCFFCC">Footer 1</th>
  53.                 <th style="width: 30%; text-align: left; border: solid 1px #337722; background: #CCFFCC">Footer 2</th>
  54.             </tr>
  55.         </tfoot>
  56.     </table>
  57.     <br>
  58.     Ca marche !!!<br>
  59.     refaisons un test : <br>
  60.     <table style="width: 80%;border: solid 1px #5544DD">
  61. <?php
  62.     for ($k=0; $k<12; $k++) {
  63. ?>
  64.         <tr>
  65.             <td style="width: 30%; text-align: left; border: solid 1px #55DD44">
  66.                 test de texte assez long pour engendrer des retours à la ligne automatique...
  67.                 a b c d e f g h i j k l m n o p q r s t u v w x y z
  68.                 a b c d e f g h i j k l m n o p q r s t u v w x y z
  69.             </td>
  70.             <td style="width: 70%; text-align: left; border: solid 1px #55DD44">
  71.                 test de texte assez long pour engendrer des retours à la ligne automatique...
  72.                 a b c d e f g h i j k l m n o p q r s t u v w x y z
  73.                 a b c d e f g h i j k l m n o p q r s t u v w x y z
  74.  
  75.             </td>
  76.         </tr>
  77. <?php
  78.     }
  79. ?>
  80.     </table>
  81.     <br>
  82.     Ca marche toujours !<br>
  83.     De plus, vous pouvez faire des sauts de page manuellement en utilisant les balises &lt;page&gt; &lt;/page&gt;, comme ici par exemple :
  84. </page>
  85. <page pageset="old">
  86.     Nouvelle page !!!!
  87. </page>

y esta genera el pdf de lo anterior, la probe y funciona perfecto
Código PHP:
Ver original
  1. <?php
  2. /**
  3.  * HTML2PDF Librairy - example
  4.  *
  5.  * HTML => PDF convertor
  6.  * distributed under the LGPL License
  7.  *
  8.  * @author      Laurent MINGUET <[email protected]>
  9.  *
  10.  * isset($_GET['vuehtml']) is not mandatory
  11.  * it allow to display the result in the HTML format
  12.  */
  13.  
  14.     // get the HTML
  15.     ob_start();
  16.     include(dirname(__FILE__).'/res/exemple03.php');
  17.     $content = ob_get_clean();
  18.  
  19.     // convert to PDF
  20.     require_once(dirname(__FILE__).'/../html2pdf.class.php');
  21.     try
  22.     {
  23.         $html2pdf = new HTML2PDF('P', 'A4', 'fr', true, 'UTF-8', 3);
  24.         $html2pdf->pdf->SetDisplayMode('fullpage');
  25.         $html2pdf->writeHTML($content, isset($_GET['vuehtml']));
  26.         $html2pdf->Output('exemple03.pdf');
  27.     }
  28.     catch(HTML2PDF_exception $e) {
  29.         echo $e;
  30.         exit;
  31.     }
__________________
[email protected]
HITCEL