php fpdf多单元格中的行高
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9815900/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Line height in fpdf multicell
提问by janenz00
I am using fpdf multicell to display an address. Each line in the address will be displayed in a new line like :
我正在使用 fpdf multicell 来显示地址。地址中的每一行都将显示在一个新行中,例如:
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?
但是每行之间的行高都超过了新行。知道如何在 FPDF 中为 MultiCell 设置行高吗?
回答by bboydev
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 的作用是将给定的文本展开到多个单元格中,这意味着第二个参数定义了每行(单个单元格)的高度,而不是将所有单元格的高度定义为一个集合。
MultiCell(float w, float h, string txt [, mixed border [, string align [, boolean fill]]])
MultiCell(float w, float h, string txt [, 混合边框 [, string align [, boolean fill]]])
You can read the full documentation here.
您可以在此处阅读完整的文档。
回答by jsruok
According to FPDF manualMultiCell is defined as
根据FPDF 手册MultiCell 被定义为
MultiCell(float w, float h, string txt [, mixed border [, string align [, boolean fill]]])
MultiCell(float w, float h, string txt [, mixed border [, string align [, boolean fill]]])
where h is "Height of cells".
其中 h 是“单元格的高度”。
That's a little confusing as h is the "line height" in normal language -- and the parameter you were looking for.
这有点令人困惑,因为 h 是普通语言中的“行高”——以及您正在寻找的参数。
回答by Tapfuma Gahadzikwa
//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
//Cell第二列调整行高大小
回答by user2002359
you can use a library called advanced tablewitch makes this kind of thing a piece of cake.
you can do what this guydid 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.
我的建议是图书馆,虽然它的成本约为 8 美元......相信我,它可以节省时间。