Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Creating PDF files with Perl

by holli (Monsignor)
on May 10, 2011 at 13:02 UTC ( #903976=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Creating PDF files with Perl
in thread Creating PDF files with Perl

Due to popular demand ^^, here is a hello world example:

use warnings; use strict; use Template; # create Template object my $ttt = Template->new(); # define template variables for replacement my $replacements = { name => "holli" }; my $template = join ("", <DATA>); # process input template, substituting variables and save it to disk $ttt->process( \$template, $replacements, "output.xml") || die $templa +te->error(); #call fop and translate xml file to pdf system "d:\\fop-1.0\\fop.bat -fo output.xml -pdf output.pdf" __DATA__ <?xml version="1.0" encoding="iso-8859-1"?> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:layout-master-set> <fo:simple-page-master master-name="my-page"> <fo:region-body margin="1in"/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="my-page"> <fo:flow flow-name="xsl-region-body"> <fo:block>Hello, [% name %]!</fo:block> </fo:flow> </fo:page-sequence> </fo:root>
Instead of running fop via system, you might also look at XML::ApacheFOP.


holli

You can lead your users to water, but alas, you cannot drown them.


Comment on Re^3: Creating PDF files with Perl
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://903976]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2015-07-04 05:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls