Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mPDF not adding header/footer on new pages

Tags:

php

mpdf

Essentially, the headers and footers are only displaying on the first page and the first page after I manually break the page.

But header and footer are NOT being displayed on any additional pages that are a natural continuation due to long HTML content. (i.e. where there is no manual )

<htmlpageheader name="header">Page Hader</htmlpageheader>
<htmlpagefooter name="footer"><p>Copyright <b>blablabla</b> 1999 - <?php echo date('Y') ?></p></htmlpagefooter>

Header+footer will display on this page

<sethtmlpageheader name="header" page="all" value="on" show-this-page="1" />
<sethtmlpagefooter name="footer" page="all" value="on" />


<p>(PDF cover)</p>
<h1>Report</h1>

Header+footer will display on the first page but not on subsequent pages

<pagebreak />
<sethtmlpageheader name="header" page="all" value="on" show-this-page="1" />
<sethtmlpagefooter name="footer" page="all" value="on" />
LONG HTML CONTENT
THAT EXCEEDS PAGE SIZE
like image 550
Martin Avatar asked Dec 06 '22 01:12

Martin


2 Answers

You can add @page like this:

@page {
 header: header_name;
 footer: footer_name;
}

Using @page

Headers & Footers

I hope that is useful

like image 84
Giovani Generali Avatar answered Dec 08 '22 16:12

Giovani Generali


If you use @page in styles, Removing @page resolved the problem. That was what I had, and what worked for me.

like image 23
Ceg Avatar answered Dec 08 '22 16:12

Ceg