fpdi

FPDI attaching Cell to Y (from XY) in weird way


when overlying user values over prepared table and I noticed, that all values are wrongly vertically shifted.

So I tried to manually put one on 0,0 and the result is really weird, I can see only half of the text heigh.

$fpdi->SetFont('Arial', '', 18);
$fpdi->SetTextColor(255, 0, 255);
$fpdi->SetXY(0, 0);
$fpdi->Cell(0, 0, 'Maestro Bach Johann Sebastian', 0, 0, 'L');

enter image description here

In the same way it works wrongly with $fpdi->Text(0,0, 'Maestro Bach Johann Sebastian')

I tried to move it manually by half size of font, but then it was too low on Y - I'm sure, that it is by unit incompatibility of text size (pt?) and XY position (mm?)


Solution

  • As you set the cell height to 0 this is the expected result.

    I guess that you are using pt as the $unit parameter in the constructor? If so you can e.g. pass a height in relation to your font-size:

    $fpdi->Cell(0, 18 * 1.2, 'Maestro Bach Johann Sebastian', 0, 0, 'L');