Php TCPDF和FPDI,页脚页码不起作用

Php TCPDF和FPDI,页脚页码不起作用,php,tcpdf,fpdi,Php,Tcpdf,Fpdi,我将TCPDF与FPDI结合使用。除了页脚(要在那里添加页码)之外,其他都可以正常工作 我的代码: // Extend the TCPDF class to create custom Header and Footer class MYPDF extends FPDI { // Page footer public function Footer() { // Position at 15 mm from bottom $this-&g

我将TCPDF与FPDI结合使用。除了页脚(要在那里添加页码)之外,其他都可以正常工作

我的代码:

    // Extend the TCPDF class to create custom Header and Footer
class MYPDF extends FPDI {

    // Page footer
    public function Footer() {
        // Position at 15 mm from bottom
        $this->SetY(-15);
        // Set font
        $this->SetFont('helvetica', 'I', 8);
        // Page number
        $this->Cell(0, 5, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
    }
}

// add external PDF with FPDI
$pdf = new FPDI(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', true);

// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$pdf->SetMargins(1, 4, 1, 1, true);

//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, 3);

。。。如果我不起诉FPDI,这个页脚钩子可以正常工作。我错过了什么?

您正在启动
FPDI
的实例,而不是
MYPDF
。确保不会以这种方式调用
Footer()
方法


IIRC您还必须将
setPrintFooter()
保留为true。

没有真正的帮助。一旦我使用FPDI,我就不能扩展页脚的类了?但这正是我告诉你的:启动
MYPDF
而不是
FPDI
。是的,但是如果我启动MYPDF,我就不能再使用任何FPDI函数了。(包括现有的pdf文件)。很抱歉,但是你做错了什么,这超出了我的范围。我告诉过你问题中的代码有什么问题。