As you wrote, SetHTMLHeader
and SetHTMLFooter
apply to the entire document. If you want different headers / footers for the first page you will have to remove both
$mpdf->SetHTMLHeader($header);
$mpdf->SetHTMLFooter($footer);
And do it like so:
- In your PDF's HTML code, place right after the
<body>
tag the different header definitions like so:
<htmlpageheader name="firstpage" style="display:none">
<div style="text-align:center">First Page</div>
</htmlpageheader>
<htmlpageheader name="otherpages" style="display:none">
<div style="text-align:center">{PAGENO}</div>
</htmlpageheader>
- Set your headers like this (still in you first page's code)
<sethtmlpageheader name="firstpage" value="on" show-this-page="1" />
<sethtmlpageheader name="otherpages" value="on" />
This turns on both headers but on the first page shows the "firstpage" header.
- Same goes for footers.
IMPORTANT NOTE:
There are actually a few ways to go about it. They are all documented here. I chose to write here the one I think is the most straight forward and will easily work, but I recommend you read the docs and choose the one that best suits your needs.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…