Reputation: 2104
I am trying to add a landscape page in the middle of a portrait PDF generated from HTML. I have set AutoPageBreak
to true
, but this results in the pages overlapping when I call AddPage()
. For example:
$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');
That results in the first pages displaying correctly (after being auto page broken), but the second content, pageBody2
, being overlapped on top of the first set of page(s).
Upvotes: 0
Views: 1116
Reputation: 60187
You need to change the $ln
(7th) parameter of the writeHTMLCell()
calls in your AutoPageBreak-broken pages from 0
to 1
(or 2
):
$pdf->writeHTMLCell(170, '', 20, 50, $pageBody, 0, 1, false, true, '', true);
so that the new landscape page goes to the beginning of the next line (1
) or below (2
) the last box of $pageBody
instead of to the right of it.
Upvotes: 1
Reputation:
for adding pagebreak,use
<br pagebreak="true"/>
or
<tcpdf method="AddPage" />
Upvotes: 0