diff --git a/src/Cezpdf.php b/src/Cezpdf.php index 6543e1c..09e2589 100644 --- a/src/Cezpdf.php +++ b/src/Cezpdf.php @@ -1947,7 +1947,9 @@ public function ezText($text, $size = 0, $options = array(), $test = 0) } $lines = preg_split("[\r\n|\r|\n]", $text); - foreach ($lines as $line) { + $c = count($lines); + for ($i = 0; $i < $c; $i++) { + $line = $lines[$i]; $start = 1; while (strlen($line) || $start) { $start = 0; @@ -1971,6 +1973,14 @@ public function ezText($text, $size = 0, $options = array(), $test = 0) } else { $right = $this->ez['pageWidth'] - $this->ez['rightMargin'] - ((is_array($options) && isset($options['right'])) ? $options['right'] : 0); } + + 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"; + } + } + $line = $this->addText($left, $this->y, $size, $line, $right - $left, $just, 0, 0, $test); } } diff --git a/src/Cpdf.php b/src/Cpdf.php index 2db2aa6..1a484bb 100644 --- a/src/Cpdf.php +++ b/src/Cpdf.php @@ -3003,9 +3003,10 @@ public function addText($x, $y, $size, $text, $width = 0, $justification = 'left return $v['text']; }, $parts)); - // only adjust full, when 90 percent of the width is used - if (($justification == 'full' && ($orgWidth / 100 * 90) < ($orgWidth - $width)) || $justification != 'full') { - $this->adjustWrapText($parsedText, $orgWidth - $width, $orgWidth, $x, $wordSpaceAdjust, $justification); + $this->adjustWrapText($parsedText, $orgWidth - $width, $orgWidth, $x, $wordSpaceAdjust, $justification); + + if ($test) { + return $text; } foreach (array_filter($this->callback, function ($v) {