Skip to content

Commit

Permalink
fix newline case
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaasuni committed Mar 22, 2024
1 parent 4a82a8d commit 8586dc4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions examples/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,7 @@

$txt3 = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'."\n".'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';

// single block of text
$txtbox = $pdf->getTextCol(
$txt3,
20, // float $posx = 0,
Expand All @@ -1104,6 +1105,7 @@
);
$pdf->page->addContent($txtbox);

// block of text between two page regions
$pdf->addTextCol(
$txt3,
20, // float $posx = 0,
Expand Down
2 changes: 1 addition & 1 deletion src/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ protected function splitLines(
for ($word = 0; $word < $num_lines; $word++) {
$data = $dim['split'][$word];
if (($data['septype'] == 'B') || (($data['totwidth'] - $prev_totwidth) >= $line_width)) {
if (($data['septype'] != 'B') && ($word > 0)) {
if (($word > 0) && (($data['totwidth'] - $prev_totwidth) >= $line_width)) {
$data = $dim['split'][($word - 1)];
--$word;
}
Expand Down

0 comments on commit 8586dc4

Please sign in to comment.