TCPDF table header 下一页边距不同
TCPDF table header with different margin on next page
我需要打印一个带有重复 table 的 pdf,这取决于它在第一页中正常工作的记录数量,但在下一页中 table header 更改页边距,这是在 TCPDF 上显示我的 table 的代码;
$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();
我下一页的输出是这样的:
我该如何解决才能使 table 的 header 与第一个的边距相同。
你可以这样使用它:
$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;
我需要打印一个带有重复 table 的 pdf,这取决于它在第一页中正常工作的记录数量,但在下一页中 table header 更改页边距,这是在 TCPDF 上显示我的 table 的代码;
$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();
我下一页的输出是这样的:
我该如何解决才能使 table 的 header 与第一个的边距相同。
你可以这样使用它:
$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;