是否有任何perl模块在指定位置的pdf中绘制一个表,每个单元格中的给定行和列都是空的内容?
答案 0 :(得分:11)
两个想到:
我使用PDF :: Table生成了一个简单的表格,如下所示:
use PDF::API2;
use PDF::Table;
my $pdf = PDF::API2->new( -file => 'table.pdf' );
my $table = PDF::Table->new;
my $page = $pdf->page;
my $data = [
[ 'A1', 'A2', 'A3' ],
[ 'B1', 'B2', 'B3' ],
[ 'C1', 'C2', 'C3' ],
];
$table->table( $pdf, $page, $data,
x => 50,
w => 495,
start_y => 750,
next_y => 700,
start_h => 300,
next_h => 500,
);
$pdf->save;
并使用PDF :: Report :: Table这样:
use PDF::Report;
use PDF::Report::Table;
my $pdf = PDF::Report->new( PageSize => 'A4', PageOrientation => 'Portrait' );
my $table = PDF::Report::Table->new( $pdf );
my $data = [
[ 'A1', 'A2', 'A3' ],
[ 'B1', 'B2', 'B3' ],
[ 'C1', 'C2', 'C3' ],
];
$pdf->openpage;
$pdf->setAddTextPos( 50, 50 );
$table->addTable( $data, 400 ); # 400 is table width
$pdf->saveAs( 'table.pdf' );