如何在第一页上打印页眉和页脚?
答案 0 :(得分:2)
这是一个粗略但有效的例子:
use strict;
use warnings;
use PDF::API2::Simple;
our $PageNo;
my $pdf = PDF::API2::Simple->new(
file => 'file.pdf',
header => \&header,
footer => \&footer,
);
$pdf->add_font('Verdana');
for my $page (1..3) {
$pdf->add_page;
$pdf->text( 'blah' x 300, autoflow => 'on' );
}
$pdf->save;
sub header {
$PageNo++;
return if $PageNo == 1;
shift->text( 'Header text here' );
}
sub footer {
return if $PageNo == 1;
shift->text( 'page: ' . $PageNo, x => 10, y => 10 );
}