如何解决TCPDF-自动分页符显示在上一页后的表格边框
我正在使用PHP和TCPDF使用一些简单的html表创建PDF。
我发现,由于自动分页而将表推到新页时,似乎在分页符之前画了下一张表的边框。
在屏幕快照中看到Table2的边框在第1页的底部绘制,但随后在第2页的适当位置绘制了Table2。
有什么想法吗?我尝试了许多不同的边距设置,但并不能阻止它的发生。表行设置为“ nobr”,并且它们的行为与预期的一样,如您在表2中所见,其中第二行正确地在第3页中断。
<?php
require_once('tcpdf/tcpdf.php');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION,PDF_UNIT,PDF_PAGE_FORMAT,true,'UTF-8',false);
$pdf->SetMargins(PDF_MARGIN_LEFT,PDF_MARGIN_TOP,PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetAutoPageBreak(TRUE,PDF_MARGIN_BOTTOM);
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
$pdf->SetFont('helvetica','',14);
$pdf->AddPage('L');
// --- HTML Tables ---
$table = <<<HTML
<table border="1">
<thead>
<tr>
<th colspan="2" style="background-color:#d9d9d9; text-align:center;">TABLE1</th>
</tr>
</thead>
<tr nobr="true">
<td>THIS IS TABLE 1 / ROW 1</td>
<td>Why<br>is<br>this<br>not<br>working<br>properly<br>after<br>the<br>page<br>beak.</td>
</tr>
</table>
<br>
<br>
<table border="1">
<thead>
<tr>
<th colspan="2" style="background-color:#d9d9d9; text-align:center;">TABLE2</th>
</tr>
</thead>
<tr nobr="true">
<td>THIS IS TABLE 2 / ROW 1</td>
<td>Why<br>is<br>this<br>not<br>working<br>properly<br>after<br>the<br>page<br>beak.<br><br>Why<br>is<br>this<br>not<br>working<br>properly<br>after<br>the<br>page<br>beak.<br></td>
</tr>
<tr nobr="true">
<td>THIS IS TABLE 2 / ROW 2</td>
<td>>Why<br>is<br>this<br>not<br>working<br>properly<br>after<br>the<br>page<br>beak.<br><br>Why<br>is<br>this<br>not<br>working<br>properly<br>after<br>the<br>page<br>beak.<br><br></td>
</tr>
</table>
HTML;
// -----------------
$pdf->writeHTML($table,false,'');
$pdf->Output();
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。