It seems like the order of SetX() and SetY() does matter. As you can see, the second cell-box in the example is located at following coordinates: X:10.00125/Y:80. Actually it should be at x=80. Setting Y-coordinate first fixes the problem. Is it a bug? PHP version used is 5.3.28.
<?php
require('./fpdf/fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->SetY(50);
$pdf->SetX(80);
$pdf->Cell(0,5,'Coordinates: X:'.$pdf->GetX().'/Y:'.$pdf->GetY(), 1);
$pdf->SetX(80);
$pdf->SetY(80);
$pdf->Cell(0,5,'Coordinates: X:'.$pdf->GetX().'/Y:'.$pdf->GetY(), 1);
$pdf->Output();
?>
This is obvious. Look at the source or the manual:
function SetY($y)
{
// Set y position and reset x
$this->x = $this->lMargin;
if($y>=0)
$this->y = $y;
else
$this->y = $this->h+$y;
}
So this seems to be no bug. x is reset to the left-margin, what you already noticed. You could use SetXY($x, $y) instead.
I think they wanted to have SetY to be used for placing the next paragraph, so its always aligned to the left side.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With