桌面上的TCPDF格式错误

时间:2016-04-26 18:50:24

标签: php pdf cakephp-1.3 tcpdf

你好我在编写HTML表时遇到TCPDF问题 这是我的代码:

<?php 



App::import('Vendor','xtcpdf');  
$tcpdf = new XTCPDF(); 
$textfont = 'helvetica';

$tcpdf->SetCreator('Akesse');
$tcpdf->SetAuthor('Grupo Akesse');
$tcpdf->SetTitle('Reporte de mantenimiento');
$tcpdf->setPrintHeader(true);
$tcpdf->setPrintFooter(true);
$tcpdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$tcpdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$tcpdf->xheadercolor = array(255, 255, 255);
$tcpdf->xheadertext = "";
$tcpdf->xfootertext = "Av. Italia 5226 – Tel.: 2613 4089 – Fax: 2613 8277 -  www.grupoakesse.com.uy";
$tcpdf->AddPage();


$clienteact = "";
$htmlcontent = "<table>
                    <thead>
                        <th>Fecha</th>
                        <th>Nro. Servicio</th>
                        <th>Detalle</th>
                        <th>Art&iacute;culo</th>
                        <th>Costo</th>
                    </thead>
                    <tbody>";


    foreach ($data as $d) :                                                 
        $fecha = implode('/', array_reverse(explode('-', $d['c']['fecha'])));


         if ($clienteact == "") :           
             $htmlcontent .= "<tr><td colspan='5' style='text-align: center;'>" 
             . $d['c']['numero_cliente'] . ' ' 
             . $d['c']['nombre_apellido'] . "</td></tr>";            
            $clienteact = $d['c']['numero_cliente'];
            if (strlen($d['c']['nombre_apellido']) > 0) :
                $clienteact = $d['c']['nombre_apellido'];    
            endif;          
        endif;

        if ((strlen($d['c']['nombre_apellido']) > 0 && $clienteact != $d['c']['nombre_apellido']) 
        || (strlen($d['c']['numero_cliente']) == 0 && $clienteact != $d['c']['nombre_apellido'])) :
             $htmlcontent.= "<tr><td colspan='5' style='text-align: center;'>" 
             . $d['c']['numero_cliente'] . ' ' 
             . $d['c']['nombre_apellido'] . "</td></tr>";
        endif;   

        $htmlcontent .= "<tr>
            <td>" . $fecha . "</td>
            <td>" . $d['c']['numero_servicio'] . "</td>
            <td>" . $d['c']['detalle'] . "</td>
            <td>" . $d['c']['nombre'] . "</td>
            <td style='text-align: right;'>" 
            . number_format($d['c']['total'], 2, ',', '.') . "</td>            
            </tr>";                                                                 
    endforeach;

    $htmlcontent .= "</tbody></table>";  
    //echo $htmlcontent;      
$tcpdf->writeHTML($htmlcontent, true, false, false, false, '');

echo $tcpdf->Output('mantenimiento_' . date('Y-m-d') . '.pdf', 'D'); 

?>

碰巧它只是格式化了它向右抛出的tbody的内容 Pdf

但是当我对代码做出回应时,它打印得很好,我做错了什么?任何帮助/建议将受到高度赞赏,提前感谢。

0 个答案:

没有答案