I am using MPDF in LARAVEL to create PDFs using an HTML template.
I just want to add the header at the start of the PDF and the Footer at only the End of the PDF.
$mpdf = new \Mpdf\Mpdf( [ 'mode' => 'en-GB', 'format' => 'A4', 'default_font_size' => "", 'default_font' => "", 'margin_left' => $margin_left, 'margin_right' => $margin_right, 'margin_top' => $margin_top, 'margin_bottom' => $margin_bottom,'margin_footer' => $margin_footer, 'setAutoBottomMargin' => 'stretch','setAutoTopMargin' => 'stretch', 'orientation'=>'P' ] );
$mpdf->SetDocTemplate('public/'.$template, true);
$mpdf->WriteHTML($proposal_template_html);
$mpdf->Output($name.'.pdf', 'I');
In proposal_template_html I am adding LARAVEL BLADE HTML Template with mostly Tables.
<htmlpageheader name="myHeader1">
Header HTML Code
</htmlpageheader>
My Table Content for PDF of 2 page
<htmlpagefooter name="myCustomFooter" >
Footer HTML Code
</htmlpagefooter>
<style>
@page { footer: html_myCustomFooter; }
@page { header: html_myCustomHeader; }
</style>
ISSUE
Need Header only at BEGINNING of Template
Need Footer only at END of Template
But it has been on EVERY Page which is the issue, I just want it only 1s.
I don't know if you tried it according to my suggestion or not, but it should be like this :
OR
I'm assuming you're displaying all your data directly into the table, you can use like this :
(note : mpdf can't detect the last attribute it can only detect the first attribute (:first), so we trick it )