php 使用 FPDF 在单元格中进行文本换行?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3477372/
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
Make text wrap in a cell with FPDF?
提问by Carson
Right now when I use a cell with text, it all stays on one line. I know I could use the write function, but I want to be able to specify the height and width.
现在,当我使用带有文本的单元格时,它都保留在一行上。我知道我可以使用 write 函数,但我希望能够指定高度和宽度。
This is what I have now, but as I said the text does not wrap to stay in the dimensions:
这就是我现在所拥有的,但正如我所说,文本不会换行以保持尺寸:
$pdf->Cell( 200, 40, $reportSubtitle, 1, 1 );
回答by Ed.
Text Wrap:
文本换行:
The MultiCell
is used for print text with multiple lines. It has the same atributes of Cell
except for ln
and link
.
将MultiCell
用于多行打印文本。Cell
除了ln
和之外,它具有相同的属性link
。
$pdf->MultiCell( 200, 40, $reportSubtitle, 1);
Line Height:
线高:
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 (collectively).
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.
您可以在此处阅读完整的文档。