To apply on-line for insurance coverage from my organization, you have to: 1) Fill out the web form, and then 2) print it, sign it and mail it in. The problem is that creating an HTML form that is both useable and (more or less) universally printable is an exercise in futility. As an alternative, we have a PDF form with all the fields defined. If we could take the data from the web form, use it to populate the PDF form, then we can let the Adobe Reader handling printing, giving us a more consistent result with far less effort on our part. Merging a PDF form with an FDF file is a trivial task, the challenge was to get this to happen on a Lotus Domino server in the background.
The key part of the solution is an open-source (Windows-only) tool called PDFTK. PDFTK is a command-line tool with a number of capabilities, the key one for us was the ability to merge a PDF template file with an FDF data file and save the result in yet a third PDF file. My goal was to run a WebQuerySave agent to gather the data from the web form, write it to an FDF file, execute PDFTK in the background and then return a link to the PDF (or potentially a redirect to the PDF itself) back to the user. The next question was how to write the code to create an FDF file.
My colleague already had code to create an XFDF (FDF using XML) file from a Notes form, but alas, PDFTK couldn’t handle XFDF. Some research found the answer: http://www.tgreer.com/fdfServe.html. FDF files, as it turned out, were simple to create. Here’s the code for the WebQuerySave agent:
provided by Julian Robichaux at nsftools.com.
One special note, the WebQuerySave agent must be allowed to perform restricted operations (set on the security tab on the agent properties.) Needless to say error checking is also necessary, your mileage may vary.