Closed djzort closed 6 years ago
Hi, Thanks for reporting this. Would you propose a fix as you are more familiar with the context?
Heres an example derived from the examples dir
#!/usr/bin/env perl
use warnings;
use strict;
use diagnostics;
#Please use TABSTOP=4 for best view
use PDF::API2;
use PDF::Table;
my $pdftable = PDF::Table->new;
my $pdf = PDF::API2->new( -file => 'headers.pdf' );
my $page = $pdf->page();
$pdf->mediabox('A4');
# A4 as defined by PDF::API2 is h=842 w=545 for portrait
# some data to layout
my $some_data = [
[ 'HeaderA', 'HeaderB' ],
[ 'foo', 'bar' ],
[ 'one', 'two' ],
[ 'thr', 'four score and seven years ago our fathers brought forth' ],
[ 'fiv', 'six' ],
[ 'sev', 'abcdefghijklmnopqrstuvwxyz' ],
];
# build the table layout
$pdftable->table(
# required params
$pdf,
$page,
$some_data,
x => 10,
w => 220,
start_y => 640,
next_y => 700,
start_h => 2,
next_h => 62,
# some optional params
border => 0,
font_size => 20,
font_underline => [3 ,2],
max_word_length => 13,
header_props => {
background_color => 'yellow',
repeat => 1
},
cell_props => [
[], [ { background_color => 'red' }, { background_color => 'blue' } ],
],
);
$pdf->saveas();
^ also on a second commit in the same PR
Resolved with version 0.10.0
If start_h parameter is too low, PDF::Table gets stuck in an infinite loop spewing the following error:
The $columns_number isnt defined because the line 617 code doesnt match, so $columns_number is never loaded
while(scalar(@{$data}) and $cur_y-$row_h > $bot_marg)