Shane
Shane

Reputation: 753

Custom HTML footer in TCPDF

I am trying to create a letter template in TCPDF but struggling with the footer.

I have added the below

$footertext="Registered Charity no XXX. Company Limited by Guarantee registered in England and Wales no XXX. <br>
Registered Office: ADDRESS HERE";

And then added the below in the PDF create section

public function Footer() {
        // Position at 15 mm from bottom
        $this->SetY(-15);
        // Set font
        $this->SetFont('helvetica', '', 8);
        // Page number
        $this->writeHTML($footertext, false, true, false, true);   
    }

However nothing shows?

Upvotes: 0

Views: 7219

Answers (1)

Dave
Dave

Reputation: 5191

You have to create an instance of fPDF before creating your footer function.

require('fpdf.php');
class PDF extends FPDF {
    //
    // This class extends FPDF so we may customize the header and footer
    // of the PDFs that are created
    //

    function Footer() {
        $this->SetFont('helvetica', '', 8);
        // Page number
        $this->writeHTML($footertext, false, true, false, true);   
    }  // end of the Footer function
}  // end of the PDF class

Upvotes: 2

Related Questions