Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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=""> <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.


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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://903976]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2017-12-18 11:34 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (483 votes). Check out past polls.