Link to home
Start Free TrialLog in
Avatar of freestate
freestate

asked on

TCPDF: How to have different headers/footers on different pages?

I'm using TCPDF to generate PDF documents on the fly from a database.

I need to use custom headers:

http://www.tcpdf.org/examples/example_003.phps

(from http://www.tcpdf.org/examples.php)

BUT, have hit two problems:

1. I need to suppress the footer on page one, so as not to have the page number on the title page

2. I need to vary the text in the header on each page.

I've tried calling a new Footer before each new Addpage:

class MYPDF extends TCPDF {

    // Page footer
    public function Footer() {

      if (!isset($i)) $i = 1;
      else {
        // Position at 15 mm from bottom
        $this->SetY(-15);
        // Set font
  $this->Cell(0, 0, '', T, 1, 'L', 0, '');
       $this->SetFont('helvetica', 'B', 12);
        // Title
        $this->Cell(30, 0, 'Design Out Crime ', 0, 0, 'L', 0, '');
       $this->SetFont('helvetica', 12);
        // Title
        $this->Cell(100, 0, 'Your Personalised Advice', 0, 0, 'L', 0, '');
       $this->SetFont('helvetica', 'B', 12);
       // Page number
        $this->Cell(0, 0, ''.$this->getAliasNumPage().'', 0, 0, 'R', 0, '');
      }
    }
}

But it only seems to take the first footer defined.

Can anybody help?

ASKER CERTIFIED SOLUTION
Avatar of wmadrid1
wmadrid1
Flag of Colombia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of freestate
freestate

ASKER

Perfect - exactly what I needed!

Thanks a lot!