FPDF - 通过删除页眉/页脚在最后一页创建 blank/white 页

FPDF - creating blank/white page at last page by remove Header / Footer

我遇到了有关 FPDF 页眉和页脚的问题,我想停止在 PDF 的最后一页创建页眉和页脚。我在页脚处使用了 AliasNbPages() 并且它起作用了,但它对 Header 不起作用,我认为这是因为在 AliasNbPages() 能够将总页传递到 Header 之前它已经 "created"。是否有任何可能的方法将总页数(也是最后一页)传递到页眉中并从最后一页中排除页眉?谢谢

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();

我找到了解决方案,方法非常简单,而不是在 header 中使用 {nb}。

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();

我希望我的解释没有错,希望它能帮助那些需要它的人。谢谢