mPDF not adding header/footer on new pages

Martin picture Martin · Jun 6, 2014 · Viewed 8k times · Source

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

Answer

Giovani Generali picture Giovani Generali · Nov 11, 2015

You can add @page like this:

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

Using @page

Headers & Footers

I hope that is useful