我正在使用TCPDF打印一些数据表:一个大表(虽然通常不长于一页),然后是第二个较小的表.
在某些情况下,两个表一起长于一页,因此TCPDF在第二个表的中间插入分页符.我的客户希望避免这种行为:他们宁愿将第二个表完全放在新页面上,即在表格之前插入分页符,如果两个表格都不适合单个页面.
当然,如果两个表都适合一个页面,则不应使用分页符.
那么是否有人知道是否有办法指示TCPDF 不在给定的表中插入分页符?
小智 13
启动事务,插入表,检查您是否在新页面中,如果是,则回滚并在插入表之前添加页面.
非常重要:不要忘记TRUE调用回滚:
$this->startTransaction();
$start_page = $this->getPage();
$this->writeHTMLCell( 0, 0, '', '', $html, 0, 1, false, true, 'C' );
$end_page = $this->getPage();
if ($end_page != $start_page) {
$this->rollbackTransaction(true); // don't forget the true
$this->AddPage();
$this->writeHTMLCell( 0, 0, '', '', $html, 0, 1, false, true, 'C' );
}else{
$this->commitTransaction();
}
Run Code Online (Sandbox Code Playgroud)
希望它能帮助米歇尔
根据文档,有一个选项可以将nobr ="true"添加到表标记作为属性.
$tbl = <<<EOD
<table border="1" cellpadding="2" cellspacing="2" nobr="true">
<tr>
<th colspan="3" align="center">NON-BREAKING TABLE</th>
</tr>
<tr>
<td>1-1</td>
<td>1-2</td>
<td>1-3</td>
</tr>
</table>
EOD;
$pdf->writeHTML($tbl, true, false, false, false, '');
Run Code Online (Sandbox Code Playgroud)
http://www.tcpdf.org/examples/example_048.phps
| 归档时间: |
|
| 查看次数: |
6939 次 |
| 最近记录: |