Line height in fpdf multicell

被刻印的时光 ゝ 提交于 2019-12-18 18:53:47

问题


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:


  1. you can use a library called advanced table witch makes this kind of thing a piece of cake.

  2. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!