php Class Cezpdf 中的完整理由
Full Justification in php Class Cezpdf
我正在使用 Cezpdf Class 生成一些 pdf。段落看起来是对齐的,但段落的最后一行应该是左对齐的。使用我当前的代码
while ($ix < count($string_array)){
$pdf->ezText("$string_array[$ix]", 13, array('justification'=>'full'));
$ix++;
}
除了最后一段之外的所有段落的最后一行也都对齐了,这看起来很奇怪,因为最后一段的最后一行左对齐,正如我对所有段落所期望的那样。这种换行符有特殊字符吗?
我当前的三个相同段落的 pdf 文本如下所示:
仔细观察 ezText 函数可以发现仅最后一段的对齐方式发生了变化,如我的示例所示。
作为一种解决方法,我在每个 paragraph/line 的 for 循环之前保存了对齐输入,并删除了最后一段的单独处理:
public function ezText($text, $size = 0, $options = array(), $test = 0)
{
...
$justification_Input = $just;
for ($i = 0; $i < $c; $i++) {
$just = $justification_Input;
$line = $lines[$i];
$start = 1;
while (strlen($line) || $start) {
...
if ($just == 'full'){ // && $c == $i + 1) {
$tmp = $this->addText($left, $this->y, $size, $line, $right - $left, $just, 0, 0, 1);
if (!strlen($tmp)) {
$just = "left";
}
}
...
我正在使用 Cezpdf Class 生成一些 pdf。段落看起来是对齐的,但段落的最后一行应该是左对齐的。使用我当前的代码
while ($ix < count($string_array)){
$pdf->ezText("$string_array[$ix]", 13, array('justification'=>'full'));
$ix++;
}
除了最后一段之外的所有段落的最后一行也都对齐了,这看起来很奇怪,因为最后一段的最后一行左对齐,正如我对所有段落所期望的那样。这种换行符有特殊字符吗?
我当前的三个相同段落的 pdf 文本如下所示:
仔细观察 ezText 函数可以发现仅最后一段的对齐方式发生了变化,如我的示例所示。 作为一种解决方法,我在每个 paragraph/line 的 for 循环之前保存了对齐输入,并删除了最后一段的单独处理:
public function ezText($text, $size = 0, $options = array(), $test = 0)
{
...
$justification_Input = $just;
for ($i = 0; $i < $c; $i++) {
$just = $justification_Input;
$line = $lines[$i];
$start = 1;
while (strlen($line) || $start) {
...
if ($just == 'full'){ // && $c == $i + 1) {
$tmp = $this->addText($left, $this->y, $size, $line, $right - $left, $just, 0, 0, 1);
if (!strlen($tmp)) {
$just = "left";
}
}
...