use PDF::API2;
use PDF::Table;
use HTML::Parser;
use HTML::TableExtract;
$final_content = '
| Customer | Total Samples | SL Violations | Avg Availability |
|
All Customers | 183867 | 2102 | 98.85 |
Customers Below 90% Available
| Customer | Total Samples | SL Violations | Availability |
| CD date | 2256 | 913 | 59.53 % |
| QK - data | 289 | 61 | 78.89 % |
| MW - verw | 187 | 34 | 81.81 % |
| FY - werds | 228 | 30 | 86.84 % |
| 1dsfew - text | 1064 | 124 | 88.34 % |
| 1Zdfe - down | 435 | 48 | 88.96 % |
| 1vds - Corp | 563 | 61 | 89.16 % |
| 8Zer - Szerw | 288 | 29 | 89.93 % |
'; #### this i get from earlier part of program
$te = HTML::TableExtract->new( headers => ["Customer","Total Samples","SL Violations","Availability"]);
$te->parse($final_content); #this is the content i pass
my $page=0;
my $tabs=0;
foreach $ts ($te->tables) {
print "Table (", join(',', $ts->coords), "):\n";
$page++;
foreach $row ($ts->rows) {
$t=join(",",@$row);
my @row_ele = split(/,/,$t);
push(@arr,[@row_ele]); #potential problem line, need to push the rows into an array, i think it returns a reference
print "@row_ele"."\n";
}
}
my $pdftable = new PDF::Table;
my $pdf = new PDF::API2(-file => "New.pdf");
# $some_data=[[1,2,3],[2,3,4]];########data needed in this format to print in pdf table
for($k=0;$k<$page;$k++)
{
print "page is now $k\n";
my $page = $pdf->page(1);
$pdftable->table(
# required params
$pdf,
$page,
@{$arr[$k]}, #############Problem line, not proper, some mistake
-x => 10,
-start_y => 500,
-next_y => 700,
-start_h => 300,
-next_h => 500,
# some optional params
-w => 570,
-padding => 5,
-padding_right => 10,
-background_color_odd => "white",
-background_color_even => "yellow", #cell background color for even rows
);
}
$pdf->save;