[Catalyst] [Announce] Catalyst::View::PDF::Reuse released

JJ jj.mailinglists at gmail.com
Sat Feb 7 16:29:16 GMT 2009


Hi,

I've just released Catalyst::View::PDF::Reuse to CPAN. [1]

This is a module we developed at Penny's Arcade [2] to produce
receipts and shipping labels - I gave a lighting talk about it [3] at
Milton Keynes Perl Mongers which went down well, so here it is for
everyone to use.

The purpose of the module is to allow PDF files to be created from
Template Toolkit so that nothing needs to be hard-coded in your View,
the layout can all be controlled via templates.

When using View::PDF::Reuse, TT is given a 'pdf' object which has
methods corresponding to all the functions of PDF::Reuse. So by taking
advantage of PDF::Reuse's [4] ability to modify existing PDF documents
(such as a blank order form created in Word), it becomes possible to
generate quite complex PDF files without writing much code.

As an example, this is all you need in your controller (having already
stashed an 'order' object):

    $c->stash->{pdf_template} = 'order_pdf.tt';
    $c->forward('View::PDF::Reuse');

then the layout commands are in order_pdf.tt, allowing all of TT's
facilities - loops, filters, and so on - to be used:

    [% pdf.prForm('customer_receipt.pdf') %]
    [% pdf.prText(123,643,order.number) %]
    [% pdf.prText(299,643,order.date) %]

If anyone has any suggestions for improvement, please let me know.


Cheers,

JJ

[1] http://search.cpan.org/dist/Catalyst-View-PDF-Reuse
[2] http://www.pennysarcade.co.uk
[3] http://www.pennysarcade.co.uk/files/Creating_PDF_files_with_Catalyst.pdf
[4] http://search.cpan.org/dist/PDF-Reuse

-- 
JJ <jj at jonallen.info>
http://perl.jonallen.info  ::  http://perldoc.perl.org

Stylish accessories to enhance your home... http://www.pennysarcade.co.uk



More information about the Catalyst mailing list