Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

PDF Form Fill out...

by mkenney (Beadle)
on Nov 07, 2003 at 04:50 UTC ( #305230=perlquestion: print w/replies, xml ) Need Help??

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

There has got to be an easy way!

All I want to do is let the layout people create PDF documents and then I will fill out the data elements. I want to be able to creat enrollment forms, letters, etc. to be mailed out etc. I was hoping for something like HTML::Template on the PDF side, but have not found something even close. I'm not talking about graphics or anything of the sort, just putting names and addresses into a PDF file to create a document that can be printed and mailed.


Replies are listed 'Best First'.
Re: PDF Form Fill out...
by ant9000 (Monk) on Nov 07, 2003 at 09:18 UTC
    You might want to google around for Adobe PDF forms technology and FDF data merging tools... there are a number of programs for autofilling-in forms that might suit your needs.
    An example of what I'm saying (dunno the program, it just seems promising) is here: PDFtoolkit
    I've been looking for a Perl solution on CPAN: seems the best way to go is the module PDF::Reuse, which, among quite a few other things, does enable you to programmatically fill in forms in pdf files.
    And yes, it's as simple as this:
    use PDF::Reuse; prDocDir('doc'); prFile('Ex17.pdf'); prField('First_Name', 'Lars'); prField('Surname', 'Lundberg'); prField('City', 'Stockholm'); prField('Country', 'Sweden'); prDocForm('doc/Ex16.pdf'); prEnd();
    where doc/Ex16.pdf is the original pdf with the form (code copied from the online tutorial).
    If it works as advertised, that's a great tool!
      I think you hit the nail on the head!!!

      This module looks great from the little I just played with it. I'm guessing I have to define the fields in a special way in Acrobat, Is this true? I can get it to add text, GREAT, does the field keep the font, etc of the existing text, and is there a trick to defining the fields. I really think this is going to be the answer to my head-aches.

Re: PDF Form Fill out...
by jdtoronto (Prior) on Nov 07, 2003 at 05:01 UTC
    Well, why not use HTML::Template? The name HTML template is something of a misnomer. The template need not be HTML. I use a CSS stylesheet to produce the view I want and then convert to PDF on a PC (WHole app runs on a PC). Of course there is also Template Toolkit which is, by my reading, well suited to producing all sorts of documents. There is now a PDF::Template too. PDF::Api2 is good at actually producing the PDF. Then there is HTML::HTMLDoc which is said to produce PDF from HTML but I haven't actually tried it.

    A trip to your friendly local CPAN store will surely supply your needs!

    Good luck jdtoronto

Re: PDF Form Fill out...
by mandog (Curate) on Nov 07, 2003 at 05:17 UTC
Re: PDF Form Fill out...
by skillet-thief (Friar) on Nov 07, 2003 at 09:58 UTC

    This would be kind of an old-fashioned approach, but you could use a templating system to create LaTeX files and then generate PDF from the LaTeX files, using PDFlatex or something similar.

    This could give you high-quality pdf docs. On the downside, LaTeX can be fairly daunting.

    UPDATE: The Template Toolkit seems to have some built-in LaTeX capacities.

Re: PDF Form Fill out...
by Anonymous Monk on Nov 07, 2003 at 20:00 UTC

    OK, use htmldoc. I have been using it for report generation for four years now. If you can write clean script to generate html, then you will be very impressed by htmldoc's ability to convert html->ps/pdf.

    I have been using it for my online student information system. It is used for making letters to parents, customized course selection forms, student profiles, stats reporting, and so on. It is very slick, with tight formatting options, although no CSS yet.

    And it means you don't have to learn postscript or another crazy syntax.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (1)
As of 2023-05-28 03:40 GMT
Find Nodes?
    Voting Booth?

    No recent polls found