Segraves Form Filler - Tripod Site

Using iText to Save PDF Form Data


Introduction

This article shows how to use the iText Java library, available free from http://www.lowagie.com/iText/, to enhance a fillable, but not submittable, existing PDF form, a.k.a. Acroform, to make it possible for a user of Acrobat (or Adobe) Reader to "submit" form data to a server-side script that processes the form data and returns it to the client-side browser to be saved for future use. In addition, examples of submittable PDF forms are presented that were created solely with iText.

Background

Many fillable PDF forms, a.k.a. AcroForms, are now available, making it possible for users of the free Acrobat (or Adobe) Reader to fill a form and print it. Unfortunately, users of Reader cannot save a filled form or the form data contained therein, unless the users have versions of Acrobat (not free) that provide the required save and export functions, or the AcroForm has extensions (also not free) added to it to enable the save function in recent versions of Adobe Reader.

One capability that exists in all versions of Acrobat and Reader, from version 3 (PDF v. 1.2) to the present is the capability of submitting form data in one of several formats to a web server. This capability makes it possible for an AcroForm to be constructed in such a way that the user of Reader can submit his form data to a server and have the form data returned to his browser to be saved for future use.

Until iText, the usual way of adding actions to a fillable PDF form was to use the full distribution of Acrobat to add the required actions to an existing fillable form. With iText, it is possible (1) to enhance, without the use of Acrobat, an AcroForm to make it possible for the user with Acrobat (or Adobe) Reader to be able to save (submit) his form data to a server to be saved for future use, or (2) to create such a form entirely with iText.

Requirements

Before iText, a developer of fillable PDF forms had to have the full distribution of Acrobat to add form fields and actions to an existing PDF. With iText, this is no longer a requirement, although Acrobat is still acknowledged to be the leader in the development of tools for PDF forms.

No doubt, some consider iText to be a serious competitor of Acrobat. On the other hand, this author considers iText to be an extremely valuable adjunct to Acrobat, as iText provides the means to manipulate PDF content much more efficiently than can be done with the manual user interface, e.g., Form Tool, of Acrobat. Simply put, iText is a "must have" capability for the development of AcroForms, one that, at the same time, increases the value of Acrobat as a development tool.

For the AcroForm developer who wishes to try iText, there are several requirements (see http://www.lowagie.com/iText/ for details).

Many users of iText over the past several years have done significant work without the benefit of a book on iText. With the recent release of the eBook version of iText in Action, available now from Manning Publications web site, iText users no longer have to rely solely on the Tutorial content and scattered examples for references to use for development of their own expertise with iText.

While Acrobat is no longer the only means by which one can develop PDF forms, it is still an attractive tool for generation of PDFs. Even Bruno Lowagie, the author of iText in Action, states "It’s possible to create a document containing a PDF form (also called an AcroForm) with iText, and you’ll learn more about that in chapter 15; but using an end-user tool like Acrobat is a better way to make a quality design." Ref: Section 2.2.3, p. 55, and "In general, you won’t use iText to create your form ..." Ref: Chapter 15, p. 500. See Sections 15.4, Comparing HTML and PDF Forms, and 15.5, Summary, in the book for Bruno's detailed explanations of the latter statement.

Most of the above developer requirements can be avoided if the AcroForm already exists, but does not have any "submit" actions included in it. Indeed, there is no developer requirement at all for an existing fillable PDF form, provided the user is satisfied with the capabilities of Reader, or has a version of Acrobat that allows saving of filled PDF forms. On the other hand, many users would like to be able to save work in progress. For these users, the developer's process of Adding "submit" actions can be as simple as concatenating a PDF page with the desired "submit" (and other) actions onto the original AcroForm, or using iText to add the "submit" action directly to a pre-existing AcroForm.

Finally, for the user, there's only one major requirement for working with fillable and submittable PDF forms (AcroForms). The user's web browser must be configured to use Acrobat (or Adobe) Reader as a plugin, i.e., Reader must load the PDF form into the browser window, rather than Reader's window, in order to be able to use the "submit" actions that are supported by Reader.

Forms Demos -iText Examples

This section contains four examples that show ways in which iText can be used to enhance blank PDF forms to make them fillable and submittable. Links to the iText-Java examples and source code that were adapted by this author to generate the examples below are given.

Note: While the form data from the below submittal forms is submitted to Tripod's CGI server, it is not saved anywhere. Instead, the data is presented to you at your workstation, where you may save a copy of the form data for future use.

Questions? Comments? Please contact the author at . Thank you for your support.


Credits: Thanks to Bruno Lowagie, for his extraordinary accomplishments in developing the iText Library, for the excellent support sites he has provided, and for his book iText in Action. While the MEAP content gave this author a taste of what was to come in the eBook, the eBook exceeded all expectations. Thanks also to Olivia DiFeterici, Manning Publications, for providing the Manning Early Access Program (MEAP) content and the eBook edition of Bruno's book for this author's review.

Revision History: / 11Oct2006 - Original issue (draft orphan page) / 13Oct2006 - Released for Early Access / 16Oct2006 - Added SampleTripod example, generated solely with iText / 19Nov2006 - Added availability of eBook edition of iText in Action / 19Nov2006 - Added Example 4, based on the HelloWorldAddButton example at iText Tutorial .

Visitor Statistics: This page has been visited times.

Return to Segraves Form Filler Front Page

iText, a Free Java-PDF Library: Home Page


Copyright 2006 - William Alexander Segraves - All Rights Reserved