Link to home
Start Free TrialLog in
Avatar of rajimurali
rajimurali

asked on

Change footer for the last page in Fpdf

Hi,

I am using FPDF to generate pdf files on the fly from PHP.
I would like to change the footer of the last page alone.  Is this possible and if so how?

Thanks
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Of course it is possible.  Please post the code you are using now and tell us how we might know that we are creating the last page.  Thanks, ~Ray
ASKER CERTIFIED SOLUTION
Avatar of rajimurali
rajimurali

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
That sounds exactly like the logic I would have used.  Glad you got it on track.  ~Ray
Avatar of wazzzzza
wazzzzza

Hi,

I have exactly the same request as Raji but couldn't manage to apply his solution...
In my Footer() method, I need to set a specific footer for the last page of the pdf generated. The problem is that the number of pages can change as the pdf content is dynamically generated so I can't use a constant value. I tried to use the '{nb}' alias as a variable for the number of pages but it doesn't seem to work.

Here is my code :
		function Footer()
		{
			if($this->PageNo() < '{nb}') {
				$this->SetY(-20);
				$this->SetFont('Arial','',8);
				$this->Cell(0,3,"content for the first pages",0,1,'C');//never displayed as '{nb}' is not defined yet I guess
			}
			else {
				$this->SetY(-20);
				$this->SetFont('Arial','',8);
				$this->Cell(0,3,"content for the last page",0,1,'C');//always displayed
			}
			$this->SetFont('Arial','',8);
			$this->SetTextColor(0,0,0);
			$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,1,'C');
		}

Open in new window


Thanks for your help