Reputation: 612
I am using the latest version of mPDF to render invoices. When I initiate a loop to display the products on the order, the text often extends past the boundaries of the page and to the next. Problem is, it overlaps the header on the next page.
I would like to either disable the header on all pages, except the first page. Or alternatively, force the overflow of text to obey the margin rules of the header.
For example, I may begin looping like so:
$html .= '<div style="clear:both; margin:auto;"><table>';
foreach ($terms as $term) {
$html .= '<tr><td>'.$term.'</td></tr>';
}
$html .= '</table></div>';
If the HTML table has to continue to the next page, it just writes over the header. How can I tell mPDF to break the table up?
Upvotes: 3
Views: 4258
Reputation: 635
I was facing a such issue as well using mpdf, my savior was the use of this css property:
@media print {
#break-after {
page-break-after: always;
}
}
I put the break-after id at last div of the page, with this text on firt page will never go to next page.
Upvotes: 0
Reputation: 61
I solved this with the following:
$param = '"en-GB-x","A4","","",10,10,10,10,6,3';
$mpdf = new mPDF($param);
$html_header='<div>This is my header content</div>';
$mpdf->setAutoTopMargin='stretch';
$mpdf->setHTMLHeader($html_header);
$mpdf->WriteHTML($html,2);
$mpdf->Output($pdfFilePath, "D");
Calling the setAutoTopMargin='strech'
before adding the header solved this problem for me.
The $param
are just some default stolen from example, I haven't read what each value means.
Source: http://www.mpdfonline.com/repos/mpdfmanual.pdf (on page 107)
Upvotes: 3