在 PDF 中插入换行符 [英] Inserting line breaks into PDF
问题描述
我正在使用 PHP 即时生成一些 PDF 文件.我的问题是我需要在将插入 PDF 文件的文本的某些部分插入换行符.类似的东西:
I'm generating some PDF file on the fly using PHP. My problem is I need to insert line breaks in some part of the text that will be inserted in the PDF file. Something like:
$pdf->InsertText('Line one
Line two');
所以它打印:
第一行
第二行
我知道
对 PDF 不起作用,但是你们知道这些文件中代表换行符的任何字符或其他东西吗?
I know
doesn't work on PDF, but do you guys know any character or something that represents a line break on these files?
推荐答案
如果您使用 fpdf,为了能够使用换行符,您需要使用 此处描述的多行文本单元.
If you are using fpdf, in order to be able to use line breaks you will need to use a multi-line text cell as described here.
如果你使用它,那么你的文本中的换行符应该被正确解释和转换.
If you use this, then line breaks in your text should be interpreted and converted correctly.
举个简单的例子:
$pdf->Multicell(0,2,"This is a multi-line text string
New line
New line");
这里,2是多行文本框的高度.我不知道测量的单位是什么,或者您是否可以将其设置为 0 并忽略它.如果一开始行不通,也许可以尝试大量使用.
Here, 2 is the height of the multi-line text box. I don't know what units that's measured in or if you can just set it to 0 and ignore it. Perhaps try it with a large number if at first it doesn't work.
这篇关于在 PDF 中插入换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!