Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line height in fpdf multicell

Tags:

php

fpdf

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?

like image 962
janenz00 Avatar asked Mar 22 '12 03:03

janenz00


People also ask

How do you find the height of 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.

How do you draw a line in Fpdf?

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(); ?>


2 Answers

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.

like image 65
bboydev Avatar answered Oct 16 '22 14:10

bboydev


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.

like image 43
jsruok Avatar answered Oct 16 '22 15:10

jsruok