Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

PDF and Perl

by Anonymous Monk
on May 23, 2005 at 15:43 UTC ( [id://459596]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
I have a program that get some information from a DB and stores the results into a html template file. Now I have to also save it into PDF format.
Any one knows how to generate the pdf files using perl?
Thank you!

Replies are listed 'Best First'.
Re: PDF and Perl
by holli (Abbot) on May 23, 2005 at 15:56 UTC
    There is a variaty of modules in perl that deal with PDF, including PDF::API2, PDF::Reuse and Template::PdfTemplate. The last one looks like the best bet for you. The other two are not well suited to generate PDF conviniently from scratch.

    However, personally I prefer to create PDFs (and I do it a lot) using XSLT to produce an XSL-FO-document, which gets then translated to PDF using FOP. It's also possible to produce such an XSL-FO document via the numerous Templating engines like HTML::Mason or the Template-Toolkit.

    Note: At the time of this writing search.cpan.org is down again, so I cannot verify if the links are not broken. If so, please /msg me.



    holli, /regexed monk/
Re: PDF and Perl
by dragonchild (Archbishop) on May 23, 2005 at 15:47 UTC
    PDF::Template may be a good start.

    • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
    • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"
Re: PDF and Perl
by ghenry (Vicar) on May 23, 2005 at 16:09 UTC

    The PDF::API2 main site lists a good wiki, with a very nice tutorial.

    But, I think for your application, the above comments are probably the best way to go.

    HTH.

    Walking the road to enlightenment... I found a penguin and a camel on the way.....
    Fancy a yourname@perl.me.uk? Just ask!!!
Re: PDF and Perl
by matthewb (Curate) on May 23, 2005 at 17:34 UTC

    I have done this many, many times (despite advising clients that people don't typically like reading content in PDF format). Every time, I end up pulling my hair out trying to produce something that might be reusable in some way. There's a bunch of interesting modules on the CPAN but they all either fall short of the extensive requirements mandated by the designers involved or require a fairly intimate knowledge of the PDF specification.

    That being the case, and I'm sorry to be cynical, I have found that the best solution for me, in terms of timescale feasibility and there being some way to realise my goals, is to produce the document in question using LaTeX and then use the pdflatex utility to generate the output.

    While somewhat painful at first, the LaTeX language is learnable and quickly rewards your effort. If you're a Template Toolkit fan, there is a LaTeX filter in the distribution which, while not entirely without its problems, can ease the process a little.

    Update: added linkage.


    MB
Re: PDF and Perl
by Nevtlathiel (Friar) on May 24, 2005 at 10:27 UTC
    Depending on how complicated the document is you could try out PDF::Create. It's not very sophisticated, it doesn't do graphics, colours or any complicated drawing, but it's not that hard to pick up and it was enough to do what I wanted :)

    And just for the record, I prefer to read things in PDF format than HTML ;)

    ----------
    My cow-orkers were talking in punctuation the other day. What disturbed me most was that I understood it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://459596]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-25 23:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found