John Davidson

php - mPdf Creates a blank page


I have an html invoice that I want to convert to pdf. I used mpdf for this, but in the case of an additional page without data, how can I delete this extra page?
I used the following method but it did not work.

echo $html;
$html2 = ob_get_contents();

This is the output : img_link

my code : link

My Answer:
> AddPage();
> $mpdf->WriteHTML($html2);
> $mpdf->Output('invoice.pdf', 'D');

If you are getting a blank page at the end of your PDF, you can try adding the following code before calling the Output() method:


This will disable automatic page breaks and should prevent the extra blank page from being added to your PDF.

Rate this post

3 of 5 based on 2209 votes


© 2024 - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us