Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attach footer at very bottom to every page in tcpdf

Tags:

yii

tcpdf

I need to attach footer at the very bottom of every page. I am using tcpdf for generating pdf's. i tried many solution on google but did not found any luck. My current framework is yii and i am using tcpdf extension.

like image 493
Muhammad Shoaib Avatar asked Dec 28 '12 10:12

Muhammad Shoaib


3 Answers

you need to write Footer method in your class for example

// 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, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
like image 69
Victor9663 Avatar answered Sep 21 '22 16:09

Victor9663


Well, if you're subclassing the tcpdf class, just add a public function Footer() in which you do your stuff. It might help to set the bottom page margin to a sensible value before doing the content work, so that the Footer function has "space" to put in the footer.

like image 26
Skynet Avatar answered Sep 21 '22 16:09

Skynet


why don't you try mpdf extension i am not sure if you can get its library for yii but it has one for codeigniter and it is awesome converts css + Html to pdf accurately.

like image 44
Rana Touqeer Avatar answered Sep 19 '22 16:09

Rana Touqeer