我正在尝试在HTML中生成的纵向PDF中添加横向页面。我已将AutoPageBreak
设置为true
,但这会在我调用AddPage()
时导致页面重叠。例如:
$pageBody = "<h1>Test</h1><p>Long content here so that auto page break comes into effect</p>";
$pageBody .= "<br pagebreak=\"true\" /><h2>Page Two</h2>";
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->AddPage();
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->writeHTMLCell(170, '', 20, 50, $pageBody, 0, 0, false, true, '', true);
$pdf->endPage();
$pageBody2 = "<h1>Test Page 3 Landscape</h1>";
$pdf->AddPage('L');
$pdf->writeHTMLCell(170, '', 20, 50, $pageBody2, 0, 0, false, true, '', true);
$pdf->endPage();
$pdf->Output('my.pdf', 'I');
这导致第一页正确显示(自动页面被破坏后),但第二页内容pageBody2
重叠在第一组页面之上。
答案 0 :(得分:1)
您需要将AutoPageBreak打破页面中$ln
次调用的0
(第7个)参数从1
更改为2
(或$pdf->writeHTMLCell(170, '', 20, 50, $pageBody, 0, 1, false, true, '', true);
):
1
以便新的横向页面转到下一行(2
)或下面($pageBody
)的开头,而不是Person{
Person_ID;
Name;
Other_characteristics;
Depends_on_persons;
}
的最后一个框,而不是它的右边。
答案 1 :(得分:0)
添加分页功能,请使用
<br pagebreak="true"/>
或
<tcpdf method="AddPage" />