PDFlib PHP在textflow中的换行



我目前正在与PDFlib的第一个项目工作,需要创建一个由多个定义的文本组成的文本流。但我的问题是,这些文本之间没有断行,第二文本正好在第一文本的最后一个单词之后开始。两个单词之间甚至没有一个非换行空格

下面是我代码中的一个例子:

// First Paragraph
$optlist = "font=" . $fontRegular .
" fontsize=10" .
" fillcolor=black" .
" wordspacing=0";
$tf = $p->add_textflow(0, $firstParaqraph, $optlist);
if ($tf == 0) {
throw new Exception("Error: " . $p->get_errmsg());
}
// Second Paragraph
$optlist = "font=" . $fontRegular .
" fontsize=10" .
" fillcolor=black" .
" wordspacing=0";
$tf = $p->add_textflow($tf, $secondParaqraph, $optlist);
if ($tf == 0) {
throw new Exception("Error: " . $p->get_errmsg());
}
do {
$optlist = "blind=false";
$result = $p->fit_textflow($tf, $x + 10, 0, $textStartHalf+60, $y, "");
} while ($result == "_boxfull");
if ($result == "_stop") {
$infoHeight = $p->info_textflow($tf,'textheight');
$count = $p->info_textflow($tf, 'boxlinecount');
$y = $y - $infoHeight;
$y = $y - ($infoHeight / $count);
}
也许有人能帮我一下,我真的很感激!

现在不确定我的评论是否正确,但添加:

$tf = $p->add_textflow(0, $firstParaqraph."nn", $optlist);
// or
$tf = $p->add_textflow(0, $firstParaqraph."rnrn", $optlist);

您需要的示例:https://www.pdflib.com/pdflib-cookbook/textflow/distance_between_paragraphs/php/

最新更新