Template::Flute::PDF - PDF generator for HTML templates
Version 0.0042
$flute = Template::Flute->new (specification_file => 'invoice.xml', template_file => 'invoice.html', values => \%values); $flute->process(); $pdf = Template::Flute::PDF->new (template => $flute->template(), file => 'invoice.pdf'); $pdf->process();
Template::Flute::PDF is a PDF generator based on Template::Flute and PDF::API2.
To obtain the PDF as a string instead of writing it to a file, please simply leave out the file parameter when creating the Template::Flute::PDF object:
$pdf = Template::Flute::PDF->new (template => $flute->template(), file => 'invoice.pdf'); $pdf_as_string = $pdf->process();
Template::Flute::PDF uses the pt unit internally.
In addition, the following units are supported and automatically converted by this module:
An inch converts to 72 pt.
A centimeter converts to approximately 28.3 pt.
A millimeter converts to approximately 2.8 pt.
A pixel converts to 1 pt.
Create a Template::Flute::PDF object with the following parameters:
Template::Flute::HTML object.
PDF output file.
Page size for the PDF (default: A4).
Base directory for HTML resources like images and stylesheets.
Import parameters for Template::Flute::PDF::Import.
Top margin, defaults to 20.
Right margin, defaults to 20.
Bottom margin, defaults to 50.
Left margin, defaults to 20.
Processes HTML template and creates PDF file.
Sets the page size for the PDF.
Selects page with the given PAGE_NUM. Creates new page if necessary.
Returns the height of the content part of the page.
Returns the width of the content part of the page.
Returns the bounding box for the PDF as a hash reference with the following key/value pairs:
Top vertical position.
Left horizonal position.
Maximum width.
Maximum height.
The bounding box defines the available space without the borders.
Returns PDF::API2 font object for font NAME, WEIGHT and STYLE are optional.
Adjusts whitespace in TEXT for output in PDF.
Determines text properties for HTML template element ELT, CSS selector SELECTOR and INHERIT flag.
Calculates width and height for HTML template element ELT.
Check whether we are out of bounds with position POS and dimensions DIM.
Adds textbox for HTML template element ELT to the PDF.
Add horizontal line to PDF.
Adds borders to the PDF.
Adds rectangle to the PDF.
Determines location of an image file from the src HTML attribute.
src
$imgfile = $pdf->locate_image('images/cart.png');
The location is based on the current directory, or on the html_base constructor parameter if the src HTML attribute contains a single file name only.
html_base
Add image OBJECT to the PDF.
Starts transformation of current content object.
Ends transformation of current content object.
Converts widths to points, default unit is mm.
This is an incomplete list of supported HTML/CSS syntax.
<i>
The HTML attribute "style" is not supported.
The CSS property "display" is not supported.
The values "normal" and "bold" are supported.
The CSS property "min-height" is supported.
The CSS property "min-width" is supported.
The CSS property "text-transformation" is supported with the exception of the value "inherit".
Stefan Hornburg (Racke), <racke@linuxia.de>
Certainly a lot, as converting from HTML to PDF is quite complicated and challenging.
Please report any unknown bugs or feature requests to bug-template-flute-pdf at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Template-Flute-PDF.
bug-template-flute-pdf at rt.cpan.org
Using background color hides text.
We currently support only aligning to top or bottom of the available space. This is in contradiction to HTML, where the default vertical align is baseline (of the text).
You can find documentation for this module with the perldoc command.
perldoc Template::Flute::PDF
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Template-Flute-PDF
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Template-Flute-PDF
CPAN Ratings
http://cpanratings.perl.org/d/Template-Flute-PDF
Search CPAN
http://search.cpan.org/dist/Template-Flute-PDF/
Copyright 2010-2012 Stefan Hornburg (Racke) <racke@linuxia.de>.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Template::Flute::PDF, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Template::Flute::PDF
CPAN shell
perl -MCPAN -e shell install Template::Flute::PDF
For more information on module installation, please visit the detailed CPAN module installation guide.