X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=modules%2Foverride%2FPDF%2FTable.pm;h=81bf5d3e431ce4dfb5f536c86d41dcc2fac9a37f;hb=b70da193f851ac4e0d9d0b098a75e098e1bfd64c;hp=2dbcb98e3941aa12e7dfda82b087ebf720bed0bb;hpb=a18cc3f5dedae1c8b541b10df3b67153518663a6;p=kivitendo-erp.git diff --git a/modules/override/PDF/Table.pm b/modules/override/PDF/Table.pm index 2dbcb98e3..81bf5d3e4 100644 --- a/modules/override/PDF/Table.pm +++ b/modules/override/PDF/Table.pm @@ -135,8 +135,8 @@ sub text_block { $line_width += $arg{'indent'}; } - # Lets take from paragraph as many words as we can put into $width - $indent; - while ( @paragraph and $text_object->advancewidth( join("\x20", @line)."\x20" . $paragraph[0]) + $line_width < $width ) { + # Lets take from paragraph as many words as we can put into $width - $indent;. Always take at least one word; otherwise we'd end up in an infinite loop. + while (!scalar(@line) || (@paragraph && ($text_object->advancewidth( join("\x20", @line)."\x20" . $paragraph[0]) + $line_width < $width))) { push(@line, shift(@paragraph)); } $line_width += $text_object->advancewidth(join('', @line)); @@ -334,6 +334,7 @@ sub table { $row->[$j] =~ s#(\b\S{$max_word_len}?)(\S.*?\b)# $1 $2#; $myone = 1 if ( defined $2 ); } while( $myone ); + $row->[$j] =~ s/^\s+//; $space_w = $txt->advancewidth( "\x20" ); $column_widths->[$j] = 0; @@ -595,7 +596,7 @@ sub table { if ($remaining_header_rows) { $remaining_header_rows--; } else { - $row_cnt++; + $row_cnt++ unless $do_leftovers; } }# End of while(scalar(@{$data}) and $cur_y-$row_h > $bot_marg) @@ -980,6 +981,7 @@ Stone Environmental Inc. (www.stone-env.com). The text_block() method is a slightly modified copy of the one from Rick Measham's PDF::API2 tutorial at http://pdfapi2.sourceforge.net/cgi-bin/view/Main/YourFirstDocument +update: The tutorial is no longer available. Please visit http://pdfapi2.sourceforge.net . by Desislav Kamenov