PDF Forms

Dan Cocos's picture

Senior Software Architect


PDF Forms

One of our clients has a simple enough request. They wanted a PDF form to be populated in with a set of values gathered from a web form. We decided to settle on xfdf as a method to do this.

I wasn't familiar with xfdf, but was pleased to discover it is an easy format.

<?xml version="1.0" encoding="UTF-8"?>
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
  <field name="firstname">
  <field name="lastname">
  <field name="email">
<f href="example.pdf"/>

Now that the xfdf problem was solved we had to move on next to adding the fields to the PDF. We were unable to find suitable PHP libraries to handle it. Luckily there is a free and open source Java* library iText that does all of this and more.
Miles an EchoDitto intern took the first crack at it and had a working example in no time. A little bit of code clean up and voila a short while later a working tool to merge form data into a PDF.

*There is also a C# port for those so inclined.

I see you like to read printed material. You should check out Nicco's book The End of Big: http://endofbig.com