Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 romping around the Monastery: (3)
As of 2014-09-17 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (56 votes), past polls