} # line 615
### insert this
if (ref $arg{cell_render_hook} eq 'CODE') {
$arg{cell_render_hook}->(
$page,
$rows_counter,
$j,
$cur_x,
$cur_y-$row_h,
$calc_column_widths->[$j],
$row_h
);
}
###
$cur_x += $calc_column_widths->[$j]; # orig. line 616
}#End of for(my $j.... # orig. line 617
####
page-obj, row-index, column-index, x, y, width, height
####
use strict;
use PDF::API2;
use PDF::Table;
my $pdftable = new PDF::Table;
my $pdf = new PDF::API2(-file => "table-1.pdf");
$pdf->preferences(
-thumbs => 1,
);
sub newpage {
my $page = $pdf->page;
$page->mediabox(792,612);
return $page;
}
my $page = newpage();
# some data to layout
my $some_data =[
# same data as in your code... (not duplicated for brevity)
];
# build the table layout
$pdftable->table(
# required params
$pdf,
$page,
$some_data,
x => 70,
w => 650,
start_y => 550,
next_y => 550,
start_h => 500,
next_h => 500,
# some optional params
padding => 5,
padding_right => 10,
background_color_odd => "gray",
background_color_even => "lightblue", #cell background color for even rows
new_page_func => \&newpage, # as defined above
cell_render_hook => sub { # this is our newly introduced callback function
my ($page, $row, $col, $x, $y, $w, $h) = @_;
if ($col == 0) { # do nothing except for first column
my $url = "http://www.somewhere.com/my.php?row=$row";
my $annot = $page->annotation();
$annot->url(
$url,
-rect => [$x, $y, $x+$w, $y+$h],
-border => [1,1,1]
);
}
},
),
# do other stuff with $pdf
$pdf->saveas();