Reputation: 55
When using SetY in FPDF the content seems to not be placed based on the bottom of a page. I've tried using their example of a footer:
class PDF extends FPDF
{
// Page footer
function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Page number
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
And also just placing it at the end of my page:
//Regular page content
$pdf->Cell(40,10,'Apple and iPhone are trademarks of Apple Inc., registered in the U.S. and other countries.');
//Footer content
$pdf->SetY(-15);
// Arial italic 8
$pdf->SetFont('Arial','I',8);
// Page number
$pdf->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
$pdf->Output();
But both seem to be relative to the content that is already loaded on the pdf page, not based on the bottom of the page. If the content of the page is 40 lines, the footer content will load on the same page. If the content of the page is 100 lines, the footer content is displayed at the top of a new page.
Any input is appreciated.
Upvotes: 0
Views: 3510
Reputation: 91
I'm 6-1/2 years late to the party, for but the next poor sap with this same problem:
The solution for me was to add $pdf->SetAutoPageBreak(false);
No idea why the position Y at the bottom doesn't always work as intended and instead pushes the new item to a new page... but turning off AutoPageBreak() was the fix for me.
Upvotes: 1
Reputation: 434
Try setting the Y to be positive. ex: $pdf->SetY(240);
It wil set the position realtive to the top of the page.
Upvotes: 1