Reputation: 67
I need to set the header for FIRST page only and the footer for every page. Can't figure a way and I've been search for the solution DAYS already. Currently my code goes like this
$mpdf=new mPDF();
$mpdf->useOddEven = true;
$mpdf->SetHTMLHeader('<div style="text-align: right;"><img src="var:images"
width="80px"/></div>', 'O');
$mpdf->SetHTMLFooter('<div style="text-align: left; font-family: Arial, Helvetica,
sans-serif; font-weight: bold;font-size: 7pt; ">Footer</div>');
$html = 'Content';
$mpdf->WriteHTML($html);
$mpdf->Output();
I've set the header to Odd however, both header and footer appears on other odd page (3, 5, 7,... page). Is there a way to make the header first page only but the footer appears in every page?
Currently using MPDF5.6
Upvotes: 3
Views: 22873
Reputation: 91
According to the Documentation: https://mpdf.github.io/reference/mpdf-functions/sethtmlheader.html
The Third Parameter is:
write If TRUE it forces the Header to be written immediately to the current page. Use if the header is being set after the new page has been added. DEFAULT: FALSE
SO..
$mpdf->SetHTMLHeader('<div style="text-align: right;"><img src="var:images" width="80px"/></div>', 'O', true);
$mpdf->SetHTMLHeader('');
$footer = array (
'L' => array (
'content' => 'Footer',
'font-size' => 7,
'font-style' => 'B',
'font-family' => 'Arial, Helvetica, sans-serif',
'color'=>'#000000'
),
'C' => array (
'content' => '',
'font-size' => 10,
'font-style' => 'B',
'font-family' => 'serif',
'color'=>'#000000'
),
'R' => array (
'content' => '',
'font-size' => 10,
'font-style' => 'B',
'font-family' => 'serif',
'color'=>'#000000'
),
'line' => 1,
);
$mpdf->SetFooter($footer);
Only the SetFooter Method can set for the footer for both ODD & EVEN pages.
Upvotes: 4