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

I received a question from a workmate: "We're hoping to create some reports in PDF format to present some data, and we were hoping to use a Perl script to help us do this. The data will be in the form of text, tables and graphs."

I noticed some Perl monks nodes: Generating PDF, PDF via Perl?, Producing documents using Perl but these seem fairly old, so I was wondering what is the current state of play re PDF and Perl.

I get the impression that PDF::API2 is the way to go for serious PDF work. It seems an active SourceForge project. Is that right? Any other good alternatives?

I also noticed the O'Reilly book Perl Graphics Programming covers PDF a bit. Is it a good book? Any other good books on this subject?

Replies are listed 'Best First'.
Re: PDF and Perl
by nite_man (Deacon) on May 29, 2003 at 06:25 UTC
    You can use:
    • PDF - a library for PDF access and manipulation in Perl
    • PDF::Template - Perl extension for separation of data and PDF document layout
    • HTML::HTMLDoc - Perl interface to the htmldoc - power tool for producing PDF-Files from HTML-Content
    • PDF::Create - create PDF files
    • PDF::Reuse - Perl extention for reusing and mass producing PDF documents
    I think that it's enough. I use htmldoc directly for producing print view of my documents which created as HTML pages. It's very useful, power and easy using tool. But it has some disadvantages, of course. If you call this programm like this:
    open (HTMLDOC, "|htmldoc -f PDF --webpage") or die $!; ... close HTMLDOC or die $!;
    and if there is a some error or warning (too much large table, for example), pipe is closed immediate and return no error code or message. It's a bug of programm and I spent a lot of time for finding this problem. And the latest version does not currently support stylesheets.
          
    --------------------------------
    SV* sv_bless(SV* sv, HV* stash);
    
Re: PDF and Perl
by Popcorn Dave (Abbot) on May 29, 2003 at 06:12 UTC
    I can't tell you about PDF::API2, but I did use PDF::Labels and PDF::Create to output PDF files and they worked perfectly. The one thing I did discover is that I needed to turn off the print to fit option when printing the file as it sort of shrunk my page and the labels were not spacing properly.

    If you're printing full pages that may or may not be a problem.

    Good luck!

    There is no emoticon for what I'm feeling now.

Re: PDF and Perl
by edoc (Chaplain) on May 29, 2003 at 10:01 UTC

    You may also want to look at PDF::Report which is a wrapper around PDF::API2. I haven't used it, only used PDF::API2 directly, but it looks like it might make things a bit simpler.

    cheers,

    J

Re: PDF and Perl
by WrongWay (Pilgrim) on May 29, 2003 at 16:38 UTC
    Using linux. I like the quick, easy and lazy way.
    html2ps and ps2pdf
    Sure its not the most elegant solution, but in many cases I already have the html generated and laid out so its the fastest to production for me. Its also nice to have a postscript version of the document, as it makes it easy to use ps2g3 to make a document suitable for faxing. I beleive ghostscript is required...
    WrongWay