.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Catalyst::View::PDF::Reuse 3pm" .TH Catalyst::View::PDF::Reuse 3pm "2021-01-07" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Catalyst::View::PDF::Reuse \- Create PDF files from Catalyst using Template Toolkit templates .SH "SYNOPSIS" .IX Header "SYNOPSIS" Create a PDF::Reuse view: .PP .Vb 1 \& script/myapp_create.pl view PDF::Reuse PDF::Reuse .Ve .PP In MyApp.pm, add a configuration item for the template include path: .PP .Vb 3 \& _\|_PACKAGE_\|_\->config(\*(AqView::PDF::Reuse\*(Aq => { \& INCLUDE_PATH => _\|_PACKAGE_\|_\->path_to(\*(Aqroot\*(Aq,\*(Aqtemplates\*(Aq) \& }); .Ve .PP In your controller: .PP .Vb 2 \& $c\->stash\->{pdf_template} = \*(Aqhello_pdf.tt\*(Aq; \& $c\->forward(\*(AqView::PDF::Reuse\*(Aq); .Ve .PP In \fIroot/templates/hello_pdf.tt\fR: .PP .Vb 3 \& [% pdf.prFont(\*(AqHelvetica\-Bold\*(Aq) %] \& [% pdf.prFontSize(20) %] \& [% pdf.prText(100,100,\*(AqHello, World!\*(Aq) %] .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Catalyst::View::PDF::Reuse provides the facility to generate \s-1PDF\s0 files from a Catalyst application by embedding PDF::Reuse commands within a Template Toolkit template. .SS "Template Syntax" .IX Subsection "Template Syntax" Within your template you will have access to a \f(CW\*(C`pdf\*(C'\fR object which has methods corresponding to all of PDF::Reuse's functions. .PP For example, to print the text \fIHello, World\fR at \s-1PDF\s0 coordinates 100,100, use the following directive in your template: .PP .Vb 1 \& [% pdf.prText(100,100,\*(AqHello, World\*(Aq) %] .Ve .PP Data held in the stash can be printed as follows: .PP .Vb 1 \& $c\->stash\->{list} = [\*(Aqone\*(Aq, \*(Aqtwo\*(Aq, \*(Aqthree\*(Aq, \*(Aqfour\*(Aq]; \& \& [% y = 500 %] \& [% FOREACH item IN list %] \& [% pdf.prText(100,y,item) %] \& [% y = y \- 13 %] \& [% END %] .Ve .PP Formatting can be defined using the Template Toolkit format plugin: .PP .Vb 3 \& [% USE format %] \& [% currency = format(\*(Aq£%.2f\*(Aq) %] \& [% pdf.prText(100,100,currency(10)) %] .Ve .SS "Using existing \s-1PDF\s0 documents" .IX Subsection "Using existing PDF documents" The key benefit of PDF::Reuse is the ability to load an existing \s-1PDF\s0 file and use this as the basis for a new document. .PP For example, to produce receipts or shipping labels you could create a blank receipt in Microsoft Word, convert this to \s-1PDF,\s0 then use PDF::Reuse to add in details such as the order number and customer address. .PP .Vb 3 \& [% pdf.prForm(\*(Aqcustomer_receipt.pdf\*(Aq) %] \& [% pdf.prText(123,643,order.number) %] \& [% pdf.prText(299,643,order.date) %] .Ve .PP Note that the \s-1PDF\s0 document loaded by \f(CW\*(C`pdf.prForm\*(C'\fR must be in the same directory as your Template Toolkit template. .SH "FUNCTIONS" .IX Header "FUNCTIONS" .SS "process" .IX Subsection "process" Render the \s-1PDF\s0 file, places the contents in \f(CW\*(C`$c\->response\->body\*(C'\fR and sets appropriate \s-1HTTP\s0 headers. .PP You should normally not need to use this method directly, instead forward to the PDF::Reuse view from your controller: .PP .Vb 1 \& $c\->forward(\*(AqView::PDF::Reuse\*(Aq); .Ve .PP The filename and content disposition (inline or attachment) can be controlled by putting the following values in the stash: .PP .Vb 2 \& $c\->stash\->{pdf_disposition} = \*(Aqattachment\*(Aq; # Default is \*(Aqinline\*(Aq \& $c\->stash\->{pdf_filename} = \*(Aqmyfile.pdf\*(Aq; .Ve .PP If the \s-1PDF\s0 filename is not specified, it will be set to the last component of the \s-1URL\s0 path, appended with '.pdf'. For example, with a \s-1URL\s0 of the \s-1PDF\s0 filename would be set to \&\fI1234.pdf\fR. .SS "render_pdf" .IX Subsection "render_pdf" Renders the \s-1PDF\s0 file and returns the raw \s-1PDF\s0 data. .PP If you need to capture the \s-1PDF\s0 data, e.g. to store in a database or for emailing, call \f(CW\*(C`render_pdf\*(C'\fR as follows: .PP .Vb 1 \& my $pdf = $c\->view("PDF::Reuse")\->render_pdf($c); .Ve .SH "AUTHOR" .IX Header "AUTHOR" Jon Allen, jj@jonallen.info .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests to \f(CW\*(C`bug\-catalyst\-view\-pdf\-reuse at rt.cpan.org\*(C'\fR, or through the web interface at . I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. .SH "SUPPORT" .IX Header "SUPPORT" You can find documentation for this module with the perldoc command. .PP .Vb 1 \& perldoc Catalyst::View::PDF::Reuse .Ve .PP You can also look for information at: .IP "\(bu" 4 \&\s-1RT: CPAN\s0's request tracker .Sp .IP "\(bu" 4 AnnoCPAN: Annotated \s-1CPAN\s0 documentation .Sp .IP "\(bu" 4 \&\s-1CPAN\s0 Ratings .Sp .IP "\(bu" 4 Search \s-1CPAN\s0 .Sp .SH "SEE ALSO" .IX Header "SEE ALSO" PDF::Reuse .PP Penny's Arcade Open Source \- .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright (C) 2009 Penny's Arcade Limited .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "POD ERRORS" .IX Header "POD ERRORS" Hey! \fBThe above document had some coding errors, which are explained below:\fR .IP "Around line 73:" 4 .IX Item "Around line 73:" Non-ASCII character seen before =encoding in 'format('£%.2f')'. Assuming \s-1UTF\-8\s0