#!/usr/bin/perl
use
strict;
use
warnings;
use
PDF::Builder;
#my $compress = 'none'; # uncompressed streams
my
$compress
=
'flate'
;
# compressed streams
my
= PDF::Builder->new(
-compress
=>
$compress
);
my
$font
=
->corefont(
'Arial-Bold'
);
# input: empty page. writes current page number on it (total number of pages)
# uses global $pdf to get number of pages
sub
mark {
my
(
$page
,
$pageno
) =
@_
;
my
$t
=
$page
->text();
$t
->font(
$font
, 20);
$t
->translate(20, 700);
if
(
defined
$pageno
) {
$t
->text(
$pageno
);
# the given page number
}
else
{
$t
->text(
->pages());
# current page number 1, 2, 3,...
}
return
;
}
# create pages 1 - 8
for
(1..8) {
mark(
->page());
}
# create ninth page, inserted before old page 2
mark(
->page(2));
# create some Front Matter (TOC, etc.) pages i, ii, iii
mark(
->page(1),
'i'
);
mark(
->page(2),
'ii'
);
mark(
->page(3),
'iii'
);
->saveas(
"$0.pdf"
);
__END__