我需要打印一个带有重复表格的 pdf,具体取决于它在第一页中工作正常的记录数量,但在下一页表格标题更改边距,这是在 TCPDF 上显示我的表格的代码;
$html= '<table cellpadding="5">
<tr>
<td colspan="2" align="center"><u><h1>Resumen de Ingresos</b>
</tr>
<tr>
<td>De Fecha: {desd_fecha}</td> <td>A Fecha: {hasta_fecha}</td>
</tr>
</table>';
$total=0;
$html .=' <table border="1" cellpadding="5" width="100%">
<thead>
<tr>
<th style= "width: 150px";>Fecha</th>
<th style= "width: 90px";>Nro. Doc.</th>
<th style= "width: 280px";>Proveedor</th>
<th style= "width: 180px";>Almacen</th>
<th style= "width: 90px"; >Costo</th>
</tr>
</thead>
<tbody>';
foreach ($datos_pdf as $datos_pdfs){
$total += $datos_pdfs["DetAsiento"]["haber"];
$html .='
<tr>
<td align="center" style= "width: 150px";>'.date("d-m-Y", strtotime($datos_pdfs['CabAsiento']['fecha'])).'</td>
<td align="left" style= "width: 90px";>'.$datos_pdfs["CabAsiento"]["nro_doc"].'</td>
<td align="left" style= "width: 280px";>'.$datos_pdfs["Category"]["name"].'</td>
<td align="left" style= "width: 180px";>'.$datos_pdfs["Category"]["nro_cuenta"].'</td>
<td align="left" style= "width: 90px"; >'.$datos_pdfs["DetAsiento"]["haber"].'</td>
</tr>
</tbody>';
}
$html .='
<tr>
<td colspan="5" align="right"><b>Total: '.$total.'</b></td>
</tr>
</table>';
$fecha = new DateTime($desde);
$html = str_replace('{desd_fecha}',$fecha->format('d/m/Y'),$html);
$fecha = new DateTime($hasta);
$html = str_replace('{hasta_fecha}',$fecha->format('d/m/Y'),$html);
$pdf->writeHTML($html, true, false, false, false, '');
$pdf->lastPage();
我下一页的输出是这样的:
我怎样才能使表格的标题与第一个表格的页边距相同。
最佳答案
你可以这样使用它:
$html = <<<EOD
<table border="1" cellspacing="5" width="100%">
<thead>
<tr>
<th style= "width: 150px";>Fecha</th>
<th style= "width: 90px";>Nro. Doc.</th>
<th style= "width: 280px";>Proveedor</th>
<th style= "width: 180px";>Almacen</th>
<th style= "width: 90px"; >Costo</th>
</tr>
</thead>
<tbody>
EOD;
关于html - 下一页有不同边距的 TCPDF 表头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35141087/