I saw the other similar questions here, but I couldn't resolve my problem. My problem is: the header is working normally in all pages, but the footer is showing only on last page.
<?
$mpdf = new mPDF( '', // mode - default ''
'', // format - A4, for example, default ''
0, // font size - default 0
'', // default font family
15, // margin_left
15, // margin right
58, // margin top
60, // margin bottom
6, // margin header
0, // margin footer
'L' ); // L - landscape, P - portrait
$mpdf->SetDisplayMode('fullpage');
$cabecalho = '<div>header</div>';
$paragrafo = '<div>body</div>';
$stylesheet = "table{
width: 100%;
text-align:center;
border: 2px solid black;
}
";
$footer = "<table name='footer' width=\"1000\">
<tr>
<td style='font-size: 18px; padding-bottom: 20px;' align=\"right\">{PAGENO}</td>
</tr>
</table>";
$mpdf->SetHTMLHeader($cabecalho);
$mpdf->WriteHTML($stylesheet, 1);
$mpdf->WriteHTML($paragrafo);
$mpdf->SetFooter($footer);
$mpdf->Output();
exit;
?>
What's the problem with footer here?
try to put setFooter()
before WriteHTML()
$mpdf->SetHTMLHeader($cabecalho);
$mpdf->SetFooter($footer);
$mpdf->WriteHTML($stylesheet, 1);
$mpdf->WriteHTML($paragrafo);
$mpdf->AddPage('','','','b','off');
$mpdf->Output();
use SetHTMLFooter()
and add it before WriteHTML()
right after SetHTMLHeader()
hope that will resolve the footer issue
Other Info:
void SetHTMLFooter(String $html, string $side)
void SetFooter( $footer, $side)
SetFooter is already deprecated but will still work..
$footer = array(
'L' => array {
'content' => '',
'font-size' => 10,
'font-style' => 'B',
'font-family' => '',
'color' => '#000000'
},
'C' => array {
'content' => '',
'font-size' => 10,
'font-style' => 'B',
'font-family' => '',
'color' => '#000000'
},
'R' => array {
'content' => '',
'font-size' => 10,
'font-style' => 'B',
'font-family' => '',
'color' => '#000000'
},
'line' => 1
);
$side can be O
for Odd pages, E
for Even pages or blank for all pages.
For the documentation check this link
http://www.mpdfonline.com/repos/mpdfmanual.pdf
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