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

Evening all:

A couple of years ago I read enough LaTeX docs to be able to generate some basic output that looked reasonable.

Now I'm researching an application where I'd like to take a government form published as a pdf and combine it with the data needed to print it out, so that the final product renders as a single pdf, the government's form filled out with our data. The user should not have to figure out how to align the printer to match our print out over a preprinted form. And I need for the government folks to not balk about us not using their forms.

Please someone who know much more about the pdf spec than I do, Is this even possible? Or would I be spinning my wheels? If this is possible, what are the tools available to help me make it happen?

-- Hugh

UPDATE

bart, frodo72, Corion:

Thank you for your pointers. I've purused the docs for PDF::API2 last night and am about to delve into the PDF::Reuse perldoc next. bart put what I'm looking for better that I did above, when he says its "like using preprinted form paper in your printer."

That's what I'm looking for. Thank you. So happy someone else figured out the hard parts for me already, I hope.

-- Hugh

UPDATE #2

Well, I've been working my way through the PDF::Reuse docs, and it seems fine at creating pdf's I can read with my gui reader. But so far I haven't figured out how to hold me mouth to get the copy to print over my templates. I keep getting blank pages with the copy instead.

if( $lal && $lol ) { $life++; }

Replies are listed 'Best First'.
Re: Manipulating a pdf
by Corion (Patriarch) on Jun 12, 2006 at 07:04 UTC

    Most likely, you want to look at PDF::Template or PDF::API2, both of which can fill in PDF forms I think. If the government forms aren't actual PDF forms but merely forms that happen to be delivered in PDF format without the user being able to fill them out on the computer, you will have to do some tricky overlay manipulation of the PDF, which can (I think) only be done with PDF::API2.

    I haven't used either module.

Re: Manipulating a pdf
by bart (Canon) on Jun 12, 2006 at 08:58 UTC
    No promises made, but take a look at PDF::Reuse. What it does is open a PDF without actually parsing it, and allow you to print on top of the pages, irrespective of what is already there. It's a bit like using preprinted form paper in your printer.
Re: Manipulating a pdf
by polettix (Vicar) on Jun 12, 2006 at 08:55 UTC
    I used PDF::Reuse some time ago to do page-extraction from PDFs, with successful results; I remember that the module also supported forms and overlays, so it's another option you could investigate in your case.

    Flavio
    perl -ple'$_=reverse' <<<ti.xittelop@oivalf

    Don't fool yourself.
Re: Manipulating a pdf
by polettix (Vicar) on Jun 13, 2006 at 14:51 UTC
    Well, I've been working my way through the PDF::Reuse docs, and it seems fine at creating pdf's I can read with my gui reader. But so far I haven't figured out how to hold me mouth to get the copy to print over my templates. I keep getting blank pages with the copy instead.
    Weird! When I used PDF::Reuse I only did for page extraction and merging of documents, with nothing added to the pages, but the print was fine.

    Depending on the OS you're in, you could try to work it around:

    • in Windows, try to install PDFCreator and use the PDF printer that comes along. It could hopefully produce a cleaned up version that you can then hard-print successfully.
    • in Linux or similar, try to convert to postscript with pdf2ps or something like this, and see if the print is ok.
    Well... that's what I would try :)

    Flavio
    perl -ple'$_=reverse' <<<ti.xittelop@oivalf

    Don't fool yourself.