John Davidson

php - mPdf Creates a blank page

0 comments
Message:


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.


ob_start();  
echo $html;
$html2 = ob_get_contents();
ob_end_clean();
$mpdf->WriteHTML($html2);

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:

php
$mpdf->SetAutoPageBreak(false);


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

Comments




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