The edges of the table are not printed in TCPDF

3

At the moment of executing a PDF report from tcpdf it does not present the lines of the table even though they are the same as the objects in which part I must change in order to be presented with the edges of the table.

    $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

    // set document information
    $pdf->SetCreator(PDF_CREATOR);
    $pdf->SetAuthor('JOSE LOOR');
    $pdf->SetTitle('RECIBO DE ENTREGA');
    $pdf->SetSubject('PEDIDO');
    $pdf->SetKeywords('SACI');
    $pdf->SetPrintHeader(false);
    $pdf->SetPrintFooter(false);
    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

     // set margins
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    // set auto page breaks
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    // set some language-dependent strings (optional)
    if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
        require_once(dirname(__FILE__) . '/lang/eng.php');
        $pdf->setLanguageArray($l);
    }
     $pdf->SetFont('helvetica', '', 9, '', true);
     $pdf->AddPage('P', 'A4');
    $pdf->Image('img/logo.png', 15, 10, 180, 35, 'JPG', 'http://www.tcpdf.org', '', true, 150, '', false, false, 1, false, false, false);
    $pdf->Ln();
    $html = "<table border='1' align='center' style='text-align:center;' bordercolor='blue' cellspacing='0'>    
    <tr>
        <td width='150' >
        </td>
        <td>
          EUFRATESINVEST SA  
        </td>
        <td>
            <b>RUC:</b>  
        </td>
        <td>
            0992346531001
        </td>
    </tr>
    <tr>
        <td>
            <b>DIRECCION:</b> 
        </td>
        <td>
          KM 1 1/2 VIA LAS MERCEDES    
        </td>
        <td>
            <b>FACTURA</b>  
        </td>
        <td>
            No. 003002000004754
        </td>
    </tr>
    <tr>
        <td>
         <b>OBLIGADO A LLEVAR CONTABILIDAD</b>   
        </td>
        <td>
          SI
        </td>
        <td>

        </td>
        <td>
            0992346531001
        </td>
    </tr>
    <tr>
        <td>
       <b>NOMBRES Y APELLIDOS</b>   
        </td>
        <td>
          LUIS QUIMBULCO
        </td>
        <td>
         <b>IDENTIFICACION</b>
        </td>
        <td>
            0992346531001
        </td>
    </tr>
    <tr>
        <td>
         <b>FECHA DE EMISION:</b>   
        </td>
        <td>
          12/12/2015
        </td>
        <td>
         </b>GUIA DE REMISION:</b>
        </td>
        <td>
            0992346531001
        </td>
    </tr>
   </table>";
  $header = array('CODIGO', 'DETALLE','CANTIDAD','PRECIO','TOTAL');
  $html=utf8_encode($html);
  $pdf->writeHTML($html, true, false, true, true, '');
  $pdf->Output('example_001.pdf', 'I');
    
asked by JHOSEP LUIS LOOR ANDRADE 02.10.2016 в 03:16
source

2 answers

1

The support for HTML of TCPDF is very simple (although it is better than FPDF): link

  

Allows to preserve some HTML formatting (limited support).

     

IMPORTANT: The HTML must be well formatted - try to clean-up it using an application like HTML-Tidy before submitting. Supported tags are: a, b, blockquote, br, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, img, li, ol, p, pre, small, span, strong, sub, sup, table, tcpdf, td, th, thead, tr, tt, u, ul.

     

NOTE: all the HTML attributes must be enclosed in double-quote.

As you can see it is a very basic HTML analyzer programmed into the code: link

You should make use of more powerful document creation tools (such as DocBook) if you need the flexibility to create tables without programming the code that will generate the cells of the table you need for each record one by one.

Edit: As the article recommends, I have cleaned your HTML and put the attributes with double quotes and now it generates the edge of the table correctly:

<?php
$html = '<table border="1" align="center" bordercolor="blue" cellspacing="0">
<tr>
<td width="150"></td>
<td>EUFRATESINVEST SA</td>
<td>RUC:</td>
<td>0992346531001</td>
</tr>
<tr>
<td>DIRECCION:</td>
<td>KM 1 1/2 VIA LAS MERCEDES</td>
<td>FACTURA</td>
<td>No. 003002000004754</td>
</tr>
<tr>
<td>OBLIGADO A LLEVAR CONTABILIDAD</td>
<td>SI</td>
<td></td>
<td>0992346531001</td>
</tr>
<tr>
<td>NOMBRES Y APELLIDOS</td>
<td>LUIS QUIMBULCO</td>
<td>IDENTIFICACION</td>
<td>0992346531001</td>
</tr>
<tr>
<td>FECHA DE EMISION:</td>
<td>12/12/2015</td>
<td>GUIA DE REMISION:</td>
<td>0992346531001</td>
</tr>
</table>';

I insist that HTML support is very simple, so you probably can not ask too much. I hope it has been helpful.

    
answered by 14.10.2016 / 14:40
source
0

I recommend you see this: link It's better than passing html fragments

    
answered by 14.10.2016 в 16:30