TCPDF-自动分页符显示在上一页后的表格边框

问题描述

我正在使用PHP和TCPDF使用一些简单的html表创建PDF。

我发现,由于自动分页而将表推到新页时,似乎在分页符之前画了下一张表的边框。

在屏幕快照中看到Table2的边框在第1页的底部绘制,但随后在第2页的适当位置绘制了Table2。

有什么想法吗?我尝试了许多不同的边距设置,但并不能阻止它的发生。表行设置为“ nobr”,并且它们的行为与预期的一样,如您在表2中所见,其中第二行正确地在第3页中断。

enter image description here

<?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 (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...