Professional Documents
Culture Documents
Catalyst
Jon Allen
www.pennysarcade.co.uk/opensource
Creating PDF files with Perl
• Lots of good modules on CPAN
• PDF::API2
– Very powerful
– Lots of options
– But…
– Low-level interface
• Difficult to create complex documents
– Documentation could be better
prFile(’output.pdf’);
prForm(’template.pdf’);
prText(100,500,’Hello, World!’);
prEnd;
• Config:
__PACKAGE__−>config('View::PDF::Reuse' => {
INCLUDE_PATH =>
__PACKAGE__−>path_to('root','templates’)
});
• In your controller:
$c−>stash−>{pdf_template} = 'hello_pdf.tt';
$c−>forward('View::PDF::Reuse');
[% pdf.prForm('customer-receipt.pdf') %]
[% pdf.prText(100,500,order.number) %]
[% y = 450 %]
[% FOREACH item IN list %]
[% pdf.prText(100,y,item.name %]
[% pdf.prText(400,y,currency(item.price)) %]
[% y = y – 12 %]
[% END %]