Cataly...:Reuse(3pm)
β¨ NAME β¨
Catalyst::View::PDF::Reuse - Create PDF files from Catalyst using Template Toolkit templates
okay so bestie, welcome to the Cataly...:Reuse(3pm) manual page β filed under User Contributed Perl Documentation. This is literally the Catalyst view that creates PDF files from Catalyst using Template Toolkit templates. It's giving "PDF::Reuse commands inside a template" realness, and we're obsessed π
.
π SYNOPSIS π
Create a PDF::Reuse view first, bestie:
script/myapp_create.pl view PDF::Reuse PDF::Reuse
In MyApp.pm, add a configuration item for the template include path:
__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');
In root/templates/hello_pdf.tt:
[% pdf.prFont('Helvetica-Bold') %]
[% pdf.prFontSize(20) %]
[% pdf.prText(100,100,'Hello, World!') %]
π¦ DESCRIPTION π¦
Catalyst::View::PDF::Reuse provides the facility to generate PDF files from a Catalyst application by embedding PDF::Reuse commands within a Template Toolkit template. slay. π
πΈ Template Syntax πΈ
Within your template you will have access to a pdf object which has methods corresponding to all of PDF::Reuse's functions.
For example, to print the text Hello, World at PDF coordinates 100,100, use the following directive in your template:
[% pdf.prText(100,100,'Hello, World') %]
Data held in the stash can be printed as follows:
$c->stash->{list} = ['one', 'two', 'three', 'four'];
[% y = 500 %]
[% FOREACH item IN list %]
[% pdf.prText(100,y,item) %]
[% y = y - 13 %]
[% END %]
Formatting can be defined using the Template Toolkit format plugin:
[% USE format %]
[% currency = format('Β£%.2f') %]
[% pdf.prText(100,100,currency(10)) %]
π Using existing PDF documents π
The key benefit of PDF::Reuse is the ability to load an existing PDF file and use this as the basis for a new document. iconic behavior, honestly. β¨
For example, to produce receipts or shipping labels you could create a blank receipt in Microsoft Word, convert this to PDF, then use PDF::Reuse to add in details such as the order number and customer address.
[% pdf.prForm('customer_receipt.pdf') %]
[% pdf.prText(123,643,order.number) %]
[% pdf.prText(299,643,order.date) %]
Note that the PDF document loaded by pdf.prForm must be in the same directory as your Template Toolkit template.
π FUNCTIONS π
π process π
Render the PDF file, places the contents in $c->response->body and sets appropriate HTTP headers.
You should normally not need to use this method directly, instead forward to the PDF::Reuse view from your controller:
$c->forward('View::PDF::Reuse');
The filename and content disposition (inline or attachment) can be controlled by putting the following values in the stash:
$c->stash->{pdf_disposition} = 'attachment'; # Default is 'inline'
$c->stash->{pdf_filename} = 'myfile.pdf';
If the PDF filename is not specified, it will be set to the last component of the URL path, appended with .pdf. For example, with a URL of http://localhost/view/order/pdf/1234 the PDF filename would be set to 1234.pdf. iykyk. π«Ά
π§ render_pdf π§
Renders the PDF file and returns the raw PDF data.
If you need to capture the PDF data, e.g. to store in a database or for emailing, call render_pdf as follows:
my $pdf = $c->view("PDF::Reuse")->render_pdf($c);
π AUTHOR π
Jon Allen, jj@jonallen.info β periodt. π
π BUGS π
Please report any bugs or feature requests to bug-catalyst-view-pdf-reuse at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-View-PDF-Reuse. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
π«Ά SUPPORT π«Ά
You can find documentation for this module with the perldoc command.
perldoc Catalyst::View::PDF::Reuse
You can also look for information at:
- RT: CPAN's request tracker β
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-View-PDF-Reuse - AnnoCPAN: Annotated CPAN documentation β
http://annocpan.org/dist/Catalyst-View-PDF-Reuse - CPAN Ratings β
http://cpanratings.perl.org/d/Catalyst-View-PDF-Reuse - Search CPAN β
http://search.cpan.org/dist/Catalyst-View-PDF-Reuse
π₯ SEE ALSO π₯
PDF::Reuse- Penny's Arcade Open Source -
http://www.pennysarcade.co.uk/opensource
π COPYRIGHT & LICENSE π
Copyright (C) 2009 Penny's Arcade Limited
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
π POD ERRORS π
Hey! The above document had some coding errors, which are explained below:
Around line 73:
Non-ASCII character seen before =encoding in 'format('Β£%.2f')'.
Assuming UTF-8
so the POD parser clocked a non-ASCII character before =encoding and assumed UTF-8 β iconic little note, honestly. π
okay that's the whole page, bestie π this one is Cataly...:Reuse(3pm), from perl v5.32.0, dated 2021-01-07. go make those PDFs and slay π
β¨
π¦ where this page comes from
- debian bookworm: libcatalyst-view-pdf-reuse-perl 0.4-2.1 Β· Artistic-1.0-Perl
- debian trixie: libcatalyst-view-pdf-reuse-perl 0.4-2.1 Β· Artistic-1.0-Perl
- ubuntu jammy: libcatalyst-view-pdf-reuse-perl 0.4-2.1 Β· Artistic-1.0-Perl
- ubuntu noble: libcatalyst-view-pdf-reuse-perl 0.4-2.1 Β· Artistic-1.0-Perl
- ubuntu resolute: libcatalyst-view-pdf-reuse-perl 0.4-2.1 Β· Artistic-1.0-Perl
- ubuntu stonking: libcatalyst-view-pdf-reuse-perl 0.4-2.1 Β· Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms