use strict; use warnings; use PDF::API2; use PDF::Table; my $pdf = new PDF::API2(-file => 'test5.pdf'); my $page = $pdf->page; # Table data, two columns my $table_data1 = [ [ 'balance forward', '$ 0.00' ], [ 'credit', '$ 100.00' ], [ 'debit', '$ 200.00'], [ 'balance', '$ 100.00' ], ]; my $table_data2 = [ [ 'balance forward', '$ 0.00' ], [ 'credit', '$ 10.00' ], [ 'debit', '$ 20.00'], [ 'balance', '$ 10.00' ], ]; my $table_data3 = [ [ 'balance forward', '$ 0.00' ], [ 'credit', '$ 100,000.00' ], [ 'debit', '$ 200,000.00'], [ 'balance', '$ 100,000.00' ], ]; my $table_data4 = [ [ 'balance forward', '$ 0.00' ], [ 'credit', '$ 1.00' ], [ 'debit', '$ 2.00'], [ 'balance balance balance balance', '$ 1.00' ], ]; my $col_props = [ { font => $pdf->corefont("Courier-Bold"), width => 250, font_color => 'blue', },{ font => $pdf->corefont("Courier-Bold"), width => 50, justify => 'right', font_color => 'green', } ]; my $pdftable1 = new PDF::Table; my ($end_page, $pages_spanned, $table_bot_y) = $pdftable1->table($pdf, $page, $table_data1, -column_props => $col_props, -w => 300, -start_y => 750, -start_h => 300, -padding => 10, -x => 50, ); $table_bot_y -= 5; my $pdftable2 = new PDF::Table; ($end_page, $pages_spanned, $table_bot_y) = $pdftable1->table($pdf, $page, $table_data2, -column_props => $col_props, -w => 300, -start_y => $table_bot_y, -start_h => 300, -padding => 10, -x => 50, ); $table_bot_y -= 5; my $pdftable3 = new PDF::Table; ($end_page, $pages_spanned, $table_bot_y) = $pdftable1->table($pdf, $page, $table_data3, -column_props => $col_props, -w => 300, -start_y => $table_bot_y, -start_h => 300, -padding => 10, -x => 50, ); my $pdftable4 = new PDF::Table; $table_bot_y -= 5; $pdftable1->table($pdf, $page, $table_data4, -column_props => $col_props, -w => 300, -start_y => $table_bot_y, -start_h => 300, -padding => 5, -x => 50, ); $pdf->saveas();