Editor’s Note: This article is part of the Introduction to Acrobat Development Learning Center
What are PDF Forms?
A PDF Form is a standard PDF document that contains Form Fields. These form fields are placed onto the PDF document using Acrobat 5, Acrobat 6 Professional or Adobe Designer and saved as a normal PDF document.
Just like their HTML counterpart PDF Forms allow the author to capture information from users by way of submitting the entered forms data.
Currently the following PDF Forms fields are available:
- Text Fields
- Combo Boxes
- List Boxes
- Radio Buttons
- Check Boxes
- Digital Signatures
There are several major differences between HTML forms and PDF Forms:
- HTML forms require a web browser, PDF forms require Acrobat or Adobe Reader to be filled out.
- PDF Forms require Adobe Acrobat or Adobe Designer for their creation, anyone with Notepad and a web browser can create/view HTML forms.
- Entered data in a HTML form is generally not saved for later use, the data is submitted to an online process. PDF Forms can save their data to various formats locally1 for later processing online or viewing in Acrobat/Reader.
- To prefill a HTML form requires the construction of the entire HTML document, to prefill a PDF Form an FDF file can be constructed and later used to open the PDF with its form field data prefilled.
- In a HTML form the data and structure are the same, PDF Forms have a separation between the form fields structure and its data.
- Construction of a HTML form is far simpler than a PDF form due to the underlying structures of HTML and PDF.
What is FDF?
The Forms Data Format is a standard way to represent form field data. FDF files are based on PDF and have the same syntax and basic object types as PDF except an FDF doesn’t need to have a Cross Reference Table.
The Forms Data Format is defined and described within the Portable Document Format specification (link), under the section for Interactive Features>Interactive Forms. It’s here that you can become intimate with the inner workings, tags, objects and technical information needed to build, parse and understand FDF.
Below is an example FDF file, it describes the form fields, their properties and of course the form field data.
1 0 obj
/F(Example PDF Form.pdf)
/V(myTextField default value)
>> endobj trailer
FDF files are not complex to create; they are text and follow a very logical structure. However when you need to programmatically creates a lot of FDF files it’s useful to have a library to perform these tasks; enter the Forms Data Format Toolkit.
As mentioned the FDF Toolkit isn’t something you must have to develop or parse FDF files, it does however make life a lot simpler by automating the mundane tasks of reading and writing FDF content.
There are three flavors; Unix, Java and Windows and two versions of the FDF Toolkit available from Adobe; Version 5 and Version 6.
The Unix version of the FDF Toolkit provides wrappers for C and Perl, Windows has ActiveX, Perl and C support and the Java FDF library provides classes for Servlets, JSP and J2SE/Desktop applications.
Why Use PDF Forms
There are two main reasons to use PDF Forms. The first is the Forms Data Format (FDF) and the second reason is the ability to submit entered data in one of 5 different formats.
By providing a way to abstract the entered data from the form design it allows designers and developers the opportunity to separate two disparate functions: Design and Content.
For example an online travel shop could provide dynamic quotes from a database as an FDF file and subsequently have this loaded into a standard PDF quoting template. No special user software is required – only (at a minimum) Reader.
Entered form field data can be sent to a backend process in one of the following five formats:
- URL Encoded Format. This is the most common format for browsers. [application/x-www-form-urlencoded]
- Multipart/form-data. If you have ever uploaded a file to a web server this is the format it is sent as. [multipart/form-data]
- Forms Data Format (FDF). Essentially in the same format as you would build an FDF, this format is specific to Acrobat. [application/vnd.fdf]
- XFDF format. This is an XML-encoded version of FDF. Form Data is sent represented hierarchically. [application/vnd.adobe.xfdf]
- PDF format. Send the whole document in its entirety. [application/pdf]
This provides the developer with the greatest possible chance for easy integration into existing backend processes.
For example it’s possible to place into a Form Field a validation script, calculation script and keystroke script effectively trapping the users wrong input, adding automatically and ensuring only the correct characters are entered.
How to Develop PDF Forms
There are currently three key Adobe tools that provide Forms authoring capabilities. Acrobat v6 Professional, Acrobat v5 and Designer. Despite its name the FDF Toolkit cannot generate form fields, it can purely describe the field name that the Data belongs to.
Adobe’s latest Form tool, Designer is able to generate (automatically) PDF Forms based on Database Schema, XML Schema’s and even other PDF Forms. It can have very tight integration with XML data structures providing a seamless end-to-end process for designing, validating and storing user entered data. Along with these new development abilities it’s now possible to integrate PDF Forms into your pre-existing Web Services.
Where Are They Used?
The largest producer/consumer of PDF Forms that I have found is the United States Internal Revenue Service (IRS), as a rough count they have over 800 PDF forms in use today (http://www.irs.gov).
In this article we looked at what a PDF form is, roughly what they look like and also how they can be generated. The next step is to look at specific examples of how they can be used in a real way.