0

I'm using TCPDF in combination with FPDI. All working good except the Footer (want to add Page Numbers there).

My Code:

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

... this footer hook is working fine if I'm not suing FPDI. What do I miss here?

Oliver
  • 156
  • 1
  • 13

1 Answers1

0

You are initiating an instance of FPDI and not of MYPDF. For sure the Footer() method will not be invoked that way.

IIRC you also have to leave setPrintFooter() to true.

Jan Slabon
  • 4,736
  • 2
  • 14
  • 29