PDF Form Filling Blog

This blog is simply to document some of our findings on solutions to populate a Adobe Acrobat PDF form with data from a data base. The end result being one of two formats, one the data just being able to be modified and saved back out to the database, the other being the form being flattened with the data.
Considerations:
  • The source form has a owner password only.
  • When opening the form the fonts should always have the same alignment and size
  • Everything will be writen in ColdFusion MX 8 enviroment.
Tools/Solutions used:

Our original method the custom tag pdfconnect3. Which did a fine job of inserting data into a form, but really had no other added functionality. In decoding the custom tag, all it was really doing was creating a FDF file on the fly and merging it witht he pdf. Not rocket science, but this method worked fine until with moved to MX 8 and also added the need to flatten a populated form for the user to be able to download and/or digitally sign.

Enter Flattening a PDF. At first glance this seemed pretty simple. The tool pdfTK made short work of taking a FDF and inserting and flattening that data into our PDF. But we found that it was to not be that simple. Altho pdfTk did a fine job of inserting basic form text, it did not insert text into multiline fields properly. In our envirement our textarea fields are lined horizontally, and this alignment issue would put the text offset up about 5-6 pixels from where it should be, laying the text right in the middle of these horzontal rules. not good.

We tried ActivePDF and iText as well to resolve this problem. Only ActivePDF set the multiline fields alignment correctly out of the box. BUT (there seems to alwasy be one of these) it didn't do just about anythign else right. The biggest problem with this solution is that EVERY field you populate is automaticlly 'reset' to defaults when you populate and flatten the data. This means that any alignment, and type settings had to be read in and reset before savign the form. It also did not like 'hidden' fields and buttons in the document. After weeks with going back and forth with tech support at ActivePDF (at least these have official tech support) and having to upgrade to the full PRO version of there solution, we were able to get this to generate a flatt PDF with all the proper formatting needed. It feels like a real cluge to make work IMO.

We then upgraded to MX 8 and installed it on some new hardware so we could test off line. iText, which is now included in ColdFusion MX 8 was now also available to use. we started by trying to new ColdFusion tag <CFPDF> and <CFPDFFORM>. CFPDFFORM does a beautiful job of inserting the data into the form, when the form does NOT have a owner password. Why it doesn't work with a form with a ownerpassword set is beyond me, and must be a bug, since you don't need a ownerpassword to insert data into a PDF form. We woiuld love to see this resolved as it would be a nice and neat solution. We never got into trying to flatten the form, since we could not open a form with a ownerpassword.

So no we're on to using iText directly via ColdFusion. Oddly enough this metho opens and populates a form without a problem, while the CFPDFFORM tag, which is supose to be using iText does not work. Anyway, this method seems to have the most potential, and altho it does have the same problem with aligning the multiline field text, there is a pretty easy fix to this by using the setExtraMargin(0, 5.2) to multiline fields.

The bigger problem now with iText is that when we insert data into the PDF the data in the form fields increase in font size by like 1 or 2 pts. Altho I can solve this problem if we don't flatten the form by adding setGenerateAppearances(false); this does not work when we flatten the PDF. If we flatten with this tag we loose most of the data fields, asumingly because they are too big or too small or the offset put the text outside the original text box. We're still working on trying to resolve this issue.

 

PDF Form Filling Blog · New WebMail · Racine-Web.com Site Map · Content Management · Sites Design and Hosted by Racine Web Design · Network Operations Center · Anti-Spam with SpamBayes · Virus Alerts · Contact Us · Website Design & Web-Based content management
Server2

http://www.zomix.com/zomix