#!/usr/bin/perl -w use strict; use PDF::API2; use PDF::Table; my $pdftable = new PDF::Table; my $pdf = new PDF::API2(-file => "test.pdf"); my $page = $pdf->page; # some sample data (3 tables) my @data; for my $t (1..3) { my $table = []; for my $r (1..50) { push @$table, [ map "Table $t : $_$r", 'A'..'E' ]; } push @data, $table; } my $page_height = 700; my $top_y = 750; my $y = $top_y; for my $table (@data) { my ($p_last, undef, $y_bot) = $pdftable->table( $pdf, $page, $table, x => 50, w => 500, start_y => $y, next_y => $top_y, start_h => $page_height - ($top_y-$y), next_h => $page_height, # some optional params padding => 5, padding_right => 10, background_color_odd => "#eee", background_color_even => "#ddd", ); $page = $p_last; $y = $y_bot - 30; # vertical distance between tables if ($y < 50) { # page wrap $page = $pdf->page; $y = $top_y; } } $pdf->saveas();