1Catalyst::View::PDF::ReUusseer(3C)ontributed Perl DocumeCnattaatliyosnt::View::PDF::Reuse(3)
2
3
4

NAME

6       Catalyst::View::PDF::Reuse - Create PDF files from Catalyst using
7       Template Toolkit templates
8

SYNOPSIS

10       Create a PDF::Reuse view:
11
12        script/myapp_create.pl view PDF::Reuse PDF::Reuse
13
14       In MyApp.pm, add a configuration item for the template include path:
15
16        __PACKAGE__->config('View::PDF::Reuse' => {
17          INCLUDE_PATH => __PACKAGE__->path_to('root','templates')
18        });
19
20       In your controller:
21
22        $c->stash->{pdf_template} = 'hello_pdf.tt';
23        $c->forward('View::PDF::Reuse');
24
25       In root/templates/hello_pdf.tt:
26
27        [% pdf.prFont('Helvetica-Bold') %]
28        [% pdf.prFontSize(20) %]
29        [% pdf.prText(100,100,'Hello, World!') %]
30

DESCRIPTION

32       Catalyst::View::PDF::Reuse provides the facility to generate PDF files
33       from a Catalyst application by embedding PDF::Reuse commands within a
34       Template Toolkit template.
35
36   Template Syntax
37       Within your template you will have access to a "pdf" object which has
38       methods corresponding to all of PDF::Reuse's functions.
39
40       For example, to print the text Hello, World at PDF coordinates 100,100,
41       use the following directive in your template:
42
43        [% pdf.prText(100,100,'Hello, World') %]
44
45       Data held in the stash can be printed as follows:
46
47        $c->stash->{list} = ['one', 'two', 'three', 'four'];
48
49        [% y = 500 %]
50        [% FOREACH item IN list %]
51          [% pdf.prText(100,y,item) %]
52          [% y = y - 13 %]
53        [% END %]
54
55       Formatting can be defined using the Template Toolkit format plugin:
56
57        [% USE format %]
58        [% currency = format('£%.2f') %]
59        [% pdf.prText(100,100,currency(10)) %]
60
61   Using existing PDF documents
62       The key benefit of PDF::Reuse is the ability to load an existing PDF
63       file and use this as the basis for a new document.
64
65       For example, to produce receipts or shipping labels you could create a
66       blank receipt in Microsoft Word, convert this to PDF, then use
67       PDF::Reuse to add in details such as the order number and customer
68       address.
69
70        [% pdf.prForm('customer_receipt.pdf') %]
71        [% pdf.prText(123,643,order.number) %]
72        [% pdf.prText(299,643,order.date) %]
73
74       Note that the PDF document loaded by "pdf.prForm" must be in the same
75       directory as your Template Toolkit template.
76

FUNCTIONS

78   process
79       Render the PDF file, places the contents in "$c->response->body" and
80       sets appropriate HTTP headers.
81
82       You should normally not need to use this method directly, instead
83       forward to the PDF::Reuse view from your controller:
84
85        $c->forward('View::PDF::Reuse');
86
87       The filename and content disposition (inline or attachment) can be
88       controlled by putting the following values in the stash:
89
90        $c->stash->{pdf_disposition} = 'attachment';  # Default is 'inline'
91        $c->stash->{pdf_filename}    = 'myfile.pdf';
92
93       If the PDF filename is not specified, it will be set to the last
94       component of the URL path, appended with '.pdf'. For example, with a
95       URL of <http://localhost/view/order/pdf/1234> the PDF filename would be
96       set to 1234.pdf.
97
98   render_pdf
99       Renders the PDF file and returns the raw PDF data.
100
101       If you need to capture the PDF data, e.g. to store in a database or for
102       emailing, call "render_pdf" as follows:
103
104        my $pdf = $c->view("PDF::Reuse")->render_pdf($c);
105

AUTHOR

107       Jon Allen, jj@jonallen.info
108

BUGS

110       Please report any bugs or feature requests to
111       "bug-catalyst-view-pdf-reuse at rt.cpan.org", or through the web
112       interface at
113       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-View-PDF-Reuse>.
114       I will be notified, and then you'll automatically be notified of
115       progress on your bug as I make changes.
116

SUPPORT

118       You can find documentation for this module with the perldoc command.
119
120        perldoc Catalyst::View::PDF::Reuse
121
122       You can also look for information at:
123
124       ·   RT: CPAN's request tracker
125
126           <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-View-PDF-Reuse>
127
128       ·   AnnoCPAN: Annotated CPAN documentation
129
130           <http://annocpan.org/dist/Catalyst-View-PDF-Reuse>
131
132       ·   CPAN Ratings
133
134           <http://cpanratings.perl.org/d/Catalyst-View-PDF-Reuse>
135
136       ·   Search CPAN
137
138           <http://search.cpan.org/dist/Catalyst-View-PDF-Reuse>
139

SEE ALSO

141       PDF::Reuse
142
143       Penny's Arcade Open Source - <http://www.pennysarcade.co.uk/opensource>
144
146       Copyright (C) 2009 Penny's Arcade Limited
147
148       This program is free software; you can redistribute it and/or modify it
149       under the same terms as Perl itself.
150
151
152
153perl v5.30.1                      2020-01-29     Catalyst::View::PDF::Reuse(3)
Impressum