I need to suppress the header/footer on the last page of my PDF document. I have tried many things and have been unsuccessful. I have different headers on my first and subsequent pages which is working fine. So, what I want is to have a certain header on my first, a different header on all subsequent pages except for the last one which gets no header.
As a test, I tried setting the header on the last page to match the header on the first page. I set my named headers like this:
$mpdf->DefHTMLHeaderByName("firstpageheader",$header1);
$mpdf->DefHTMLHeaderByName("otherpageheader",$header2);
I then add my last page like this:
$mpdf->AddPageByArray(array(
"even-header-name"=>"firstpageheader",
"odd-header-name"=>"firstpageheader",
"suppress"=>"on"
));
So, my complete section of code looks like this:
$mpdf->DefHTMLHeaderByName("firstpageheader",$header1);
$mpdf->DefHTMLHeaderByName("otherpageheader",$header2);
$mpdf->WriteHTML($s); //Main document
$mpdf->AddPageByArray(array(
"even-header-name"=>"firstpageheader",
"odd-header-name"=>"firstpageheader",
"suppress"=>"on"
));
$mpdf->WriteHTML($tc); //Last page
What I wind up with on my last page is the header I defined as "otherpageheader". I do have this in the style of my main document:
@page {
header: html_otherpageheader;
footer: html_otherpagesfooter;
}
@page :first {
header: html_firstpageheader;
footer: html_firstpagefooter;
}
I don't know if that's causing the problem nor not.
The headers defined in your HTML will override what you defined when adding a new page.
Use the <sethtmlpageheader />
tag in your WriteHTML()
method to turn it off on the last page.
<sethtmlpageheader value="-1" show-this-page="1" />