I'm facing a problem regarding the FPDF Header & Footer, i would like to stop creating the header and footer at the last page of the PDF. I used AliasNbPages() at the footer and it worked, but it just doesn't work for Header and i think it is because it already "created" before AliasNbPages() able to pass in the total page into Header. Is there any possible way to pass in total page(which is also last page) into the Header and exclude the header from the last page? Thanks.
class PDF extends FPDF
{
function Header()
{
if($this->PageNo() != '{nb}')
{
//My header codes
}
}
function Footer()
{
global $totalPageForFooter;
if($this->PageNo() != $totalPageForFooter){
//My footer codes
}
}
}
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$totalPageForFooter = $pdf->PageNo();
$pdf->Output();
I've found the solution, in very simple way instead of use {nb} in header.
class PDF extends FPDF
{
function Header()
{
global $headerVisible;
if($headerVisible=="true")
{
//My header codes
}
}
function Footer()
{
global $totalPageForFooter;
if($this->PageNo() != $totalPageForFooter){
//My footer codes
}
}
}
$pdf = new PDF();
$pdf->AliasNbPages();
$headerVisible="true";
$pdf->AddPage();
//body coding goes here
$headerVisible="false"; // After the body coding finish execute, we have to clear the header first before AddPage(), if not, the $headerVisible will not valid until next header.
$pdf->AddPage(); // this one is the last empty page i wish to make it blank
$totalPageForFooter = $pdf->PageNo();
$pdf->Output();
I hope im not wrong at explaining this, hope it help someone out there who need this. Thanks.