问题
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?
回答1:
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.
回答2:
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.
回答3:
//reduce line height
$lineHeight=4;
$pdf->Cell(150,102 South Avenue',1,0,'L',true);
$pdf->Ln();
$pdf->Cell(150,Suite 107',1,0,'L',true);
$pdf->Ln();
$pdf->Cell(150,Scottsdale AZ 85260',1,0,'L',true);
$pdf->Ln();
$pdf->Cell(150,111-000-1111',1,0,'L',true);
//The Second column in the Cell adjusts line height size
回答4:
you can use a library called advanced table witch makes this kind of thing a piece of cake.
you can do what this guy did which includes adding spaces until each column has enough for a new row
My recommendation is the library although it costs around $8... its worth it for saving the time trust me.
来源:https://stackoverflow.com/questions/9815900/line-height-in-fpdf-multicell