Advanced Search  :  Site Statistics  :  Directory  :  Web Resources  :  Polls  
    AccessPDF A PDF Forum for Users and Programmers    
 Welcome to AccessPDF
 Monday, February 11 2008 @ 01:17 AM PST

Fill PDF Forms Using an HTML Front-End

   
Pdftk

I wrote an article for MacTech Magazine (Nov. 2004 ed.) about collecting form data using HTML forms and then packing this data into a PDF form for download. I posted the code online, along with a working example.

While merging data into a PDF form is old news to pdftk users, this example has an interesting twist. It uses pdftk's dump_data_fields operation to discover exactly what the PDF form wants, then creates a dynamic HTML form using this information. I.e., it automatically creates an HTML form to match your PDF form.

This HTML form is bare-bones, but it makes a good foundation for your web interface. It helps if you fill in the PDF fields' "Short Description," available via Acrobat's field properties dialog.

My MacTech article described the process in detail and introduced the reader to related topics, such as PDF forms, pdftk, and the FDF format. This artcile offers some tips on getting started and shows how to discover form field data using pdftk. Download the example PHP code here.

I haven't tested this on Adobe's new-fangled Acrobat 7 forms.



Before you start, visit the online example to get an idea for how this is supposed to work. This is also where you download the PHP source code.

First, see if you can get my example code running on your web server. If you need a web server on your Windows machine, look into IndigoPerl. Access it by pointing your browser to http://localhost/. Add material to your local web page via C:indigoperlapachehtdocs, or similar.

Get it working? Now, take the original files from my example and re-create the formtx.5.pdf.fields file. It is created from the formtx.5.pdf form using pdftk:

  pdftk formtx.5.pdf dump_data_fields output formtx.5.pdf.fields

Web page still working? Now, open formtx.5.pdf in Acrobat and try changing some of the fields. Save, then recreate the *.fields file. How does it look, now?

When you're comfortable with the process, try using your own PDF form instead of formtx.5.pdf. The "formtx.5.pdf" filename ~is~ hard-coded into my example code. Either use the same filename, or edit the PHP code.

 

What's Related

Story Options

 Copyright © 2008 AccessPDF
 All trademarks and copyrights on this page are owned by their respective owners.
Powered By Geeklog 
Created this page in 0.45 seconds