I am using mPDF in my web application.
I have to create invoice documents with the help of Mpdf.. So html table with large number of rows (ie: if it exists single page) rise this error:
Warning: Invalid argument supplied for foreach() in MPDF56/mpdf.php on line 11008
I am using following code to generate pdf:
require_once(MPDF_PATH);
$mpdf=new mPDF('c','A4','0','',2,2,2,2,1,1);
$stylesheet = file_get_contents(dirname(__FILE__).'/invoice_print.css');
$mpdf->WriteHTML($stylesheet,1);
$html .="";
$mpdf->WriteHTML($html);
$mpdf->Output("$fileName",'D');
I have tried with/without arguments in constructor of Mpdf. And I found mpdf works with first 4 params without any problem...
$mpdf=new mPDF('c','A4','0','')
But when I add "margins" (ie: 5-8) params, will throws error described above.
Have anyone has a fix for this???
I have tried with mPDF 5.3 and 5.6
Yep... I got a fix from MPDF forum...
here is the link: http://www.mpdf1.com/mpdf/forum/comments.php?DiscussionID=1109&page=1#Item_0
SOLUTION: Just replace "TableHeaderFooter" function's first line from:
if(($horf=='H' || $horf=='F') && !empty($content)) {
to:
if(($horf=='H' || $horf=='F') && !empty($content) && !empty($content[0]) ) {
Hope this will help others...
I'm working with mPDF at the moment as well. What I discovered is that you're better off setting the margins like this:
$style = '<style>
@page *{
margin-top: 2.54cm;
margin-bottom: 2.54cm;
margin-left: 3.175cm;
margin-right: 3.175cm;
}
</style>';
$mpdf->WriteHTML($style); //This writes the margin styles
$mpdf->WriteHTML($output); //This writes the html output
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With