This can be for many reasons:
1) Make sure that the elements do not have unnecessary margins and gaskets
2) Correctly set the page properties (special fields):
$page_orientation = 0; $page_size = 'Letter'; $page_margins = array('LEFT(int)','RIGHT(int)','UP(int)','BOTTOM(int)'); $pdf_output = 'I'; $css_files = array( 'path/file.css', 'path/file_2.css', ); $orientationPage = array('','-L'); /* ===== [ MPDF ] =====*/ $mpdf=new mPDF('utf-8', $page_size.$orientationPage[$page_orientation],'','',$page_margins[0],$page_margins[1],$page_margins[2],$page_margins[3]); // Loading CSS for($i = 0; $i < count($css_files); $i++){ $stylesheet = file_get_contents('../../'.$css_files[$i]); $mpdf->WriteHTML($stylesheet,1); // 1 para indicar que es CSS } // Set header & Footer (This are variables with html code) $mpdf->SetHTMLHeader($header); $mpdf->SetHTMLFooter($footer); $mpdf->SetDisplayMode('fullpage'); $mpdf->SetTitle($title); $mpdf->WriteHTML($html); // <-- insert HTML // Create PDF $mpdf->Output($titulo.'.pdf',$pdf_output);
3) Make sure you don't have any unnecessary "page breaks" in HTML
<pagebreak type="NEXT-ODD" resetpagenum="1" pagenumstyle="i" suppress="off" />
I hope this can help you!
source share