Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tcpdf edit footer

Tags:

edit

footer

tcpdf

How do I edit a footer using tcpdf? I want to add current date & time at the footer. Please help.

like image 423
lv949 Avatar asked May 13 '10 04:05

lv949


3 Answers

How can I create 2 footer lines, please?

class MYPDF extends TCPDF {
    private $customFooterText = "";

    /**
     * @param string $customFooterText
     */
    public function setCustomFooterText($customFooterText)
    {
        $this->customFooterText = $customFooterText;
    }

    public function Footer()
    {
        $this->SetY(-15);
        // Set font
        $this->SetFont('helvetica', 'I', 8);
        // Page number
        $this->Cell(0, 10, $this->customFooterText, 0, false, 'C', 0, '', 0, false, 'T', 'M');
    }
}

Usage

$pdf = new MYPDF();
$pdf->setCustomFooterText('THIS IS CUSTOM FOOTER');
like image 116
Marcos Vinícius Rinaldi Avatar answered Nov 03 '22 02:11

Marcos Vinícius Rinaldi


Override the class like this :

class MYPDF extends TCPDF {
    public function Footer() {
        $image_file = "img/bg_bottom_releve.jpg";
        $this->Image($image_file, 11, 241, 189, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);

        $this->SetY(-15);
        $this->SetFont('helvetica', 'N', 6);
        $this->Cell(0, 5, date("m/d/Y H\hi:s"), 0, false, 'C', 0, '', 0, false, 'T', 'M');
    }
}

then instead of calling :

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

do :

$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
like image 33
Oli Avatar answered Nov 03 '22 02:11

Oli


You have to extend the TCPDF class and override the Footer() method as explained on the default example n. 3. Check the official http://www.tcpdf.org website and forums for further information.

like image 29
user412934 Avatar answered Nov 03 '22 01:11

user412934