I am using fpdf multicell to display an address. Each line in the address will be displayed in a new line like :
102 South Avenue
Suite 107
Scottsdale AZ 85260
111-000-1111
But the line height between each line is more than a new line. Any idea how to set the line height for MultiCell in FPDF?
I use the FPDF's GetY() function to get current height and save it as H: $H = $pdf->GetY(); If the MultiCell's height is 5 GetY() will give back 100, if the height is 10 GetY() gives back 105 and so on.
Php require('fpdf. php'); $pdf = new FPDF(); $pdf->AddPage(); $width=$pdf->GetPageWidth(); // Width of Current Page $height=$pdf->GetPageHeight(); // Height of Current Page $pdf->Line(0, 0,$width,$height); // Line one Cross $pdf->Line($width, 0,0,$height); // Line two Cross $pdf->Output(); ?>
Height is height of each text line in multicell, not height of whole multicell element.
What multiCell does is to spread the given text into multiple cells, this means that the second parameter defines the height of each line (individual cell) and not the height of all cells as a collective.
MultiCell(float w, float h, string txt [, mixed border [, string align [, boolean fill]]])
You can read the full documentation here.
According to FPDF manual MultiCell is defined as
MultiCell(float w, float h, string txt [, mixed border [, string align [, boolean fill]]])
where h is "Height of cells".
That's a little confusing as h is the "line height" in normal language -- and the parameter you were looking for.
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