Comments
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Cloud Expo on Google News

SYS-CON.TV
Cloud Expo & Virtualization 2009 East
PLATINUM SPONSORS:
IBM
Smarter Business Solutions Through Dynamic Infrastructure
IBM
Smarter Insights: How the CIO Becomes a Hero Again
Microsoft
Windows Azure
GOLD SPONSORS:
Appsense
Why VDI?
CA
Maximizing the Business Value of Virtualization in Enterprise and Cloud Computing Environments
ExactTarget
Messaging in the Cloud - Email, SMS and Voice
Freedom OSS
Stairway to the Cloud
Sun
Sun's Incubation Platform: Helping Startups Serve the Enterprise
POWER PANELS:
Cloud Computing & Enterprise IT: Cost & Operational Benefits
How and Why is a Flexible IT Infrastructure the Key To the Future?
Click For 2008 West
Event Webcasts
Handling PDF Forms with ColdFusion
A cost-efficient alternative to Adobe's enterprise PDF server

Over the past few years government agencies and businesses have converted many of their paper forms to static PDF documents, making them available on Web sites as downloadable files for users to print locally, fill out, and submit by snail mail. All Internal Revenue Service forms are now available this way.

However, it doesn't take long to realize that if the data on mailed-in PDF documents needs to be input into a database, or if the filled-in form needs to be kept as an electronic image, it's more efficient to have the users do the data entry in the first place.

One option is to deploy Adobe's enterprise PDF server. Although powerful and elegant, this solution is very costly not only because of the hardware, operating system, and application software needed for purchasing, but also because it represents yet-another complex server to maintain and patch. A simpler and inexpensive option is to deploy a ColdFusion-accessible utility that has methods for reading and writing PDF forms. ActivePDF's 'Toolkit' is one such utility and will handle most form-entry and imaging needs.

Setting Up
ActivePDF Toolkit requires a Windows environment; the component, APToolkitNET.dll, is installed like any Windows software by invoking an executable. The component has to be registered with the CF/Web server so that when instantiated by a CF template, the operating system knows where to find it. Once installed and registered, the workflow for each PDF Web form follows this general pattern: (1) create a PDF Web form with one of several PDF Writer packages available (such as Adobe Acrobat Professional or the newly released and less expensive PDF Nitro), (2) code the ColdFusion template(s) for handling the form after a user has submitted it. This workflow is illustrated in the example below, where the user-submitted PDF form is e-mailed to a business unit and the values inserted into a database.

Create the PDF Form
Forms are usually created by a word processor or graphics program and subsequently opened in one of the PDF writers mentioned above. When open, you add form fields and a submit button via the writer's wizard. By default, the wizard will name the form fields serially (Text1, Text2...), but if the form is submitted for database insertion, the form fields should be meaningfully named. When configuring the submit button in the writer's wizard, the URL of the file to which it will be submitted should be specified; in this example, the form is submitted to 'MyBusinessForm.cfm.' After adding form fields and a submit button, save the new PDF document to a directory on your Web server. The URL of the PDF document is then advertised to potential users, which in this example might be 'http://www.serverName/aDirectory/MyBusinessForm.pdf.' Figure 1 shows a screen shot of the PDF as it appears in the browser and - without the 'Submit' and 'Reset' buttons - as an e-mail.

Handle the Form: ColdFusion coding
The form's action file in the example is 'MyBusinessForm.cfm' shown in Listing 1 at the end of this article. There are two sections.

The first section loops through the form fields, assigning its values to a structure. For testing purposes, those values are also printed to the browser screen. Next, the form's values are inserted into a database. Figure 2 shows a screen shot of running the example. You'll notice that PDF forms function much like <html..> or <cfform...> forms.

The second section is for PDF image creation. The code creates an instance of the APToolkit object and, using the methods supported by the COM component, opens and reads the original PDF ('MyBusinessForm.pdf') into memory, and then creates a new PDF image file named with a uniqueID. The next section loops through the submitted form fields and copies them into the appropriate fields in memory, removing the submit button. The next section copies the in-memory data over to the new PDF image file. After closing the image file, it's attached to an e-mail sent to the business unit and, optionally, to the user. The image file, now no longer needed, is deleted.

It's important to destroy the APToolkit object, lest you fill up the server's memory and cause a crash. The code to do it in CF v4.5 is <cfset PDF = "">; the same code will probably work in CFMX, although it might be preferable to use <cfset ReleaseComObject(PDF)>.

Enhancing the Functionality
The APToolkit object has many more methods than those demonstrated here, giving you very granular control over the formatting of the PDF image file; they are well documented in the product's literature. (The documentation also explains the parameters seen in Listing 1.)

To eliminate the possibility of the business unit's Web editors messing around in the guts of the handler, MyBusinessForm.cfm's actions should be encapsulated in a custom tag or a CFC. Another enhancement, necessary in a world infested with malware, should be filtering out form values that might perform cross-site scripting and/or sql injection attacks.

About Tim Burton
Tim Burton is the eGovernment Applications Architect for a large state agency in Oregon and has been writing CFML since 1998. This is his third career; he previously practiced medicine and made art (metal sculpture).

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

Handling PDF Forms with ColdFusion. Over the past few years government agencies and businesses have converted many of their paper forms to static PDF documents, making them available on Web sites as downloadable files for users to print locally, fill out, and submit by snail mail. All Internal Revenue Service forms are now available this way.


Your Feedback
CFDJ News Desk wrote: Handling PDF Forms with ColdFusion. Over the past few years government agencies and businesses have converted many of their paper forms to static PDF documents, making them available on Web sites as downloadable files for users to print locally, fill out, and submit by snail mail. All Internal Revenue Service forms are now available this way.
Latest Cloud Developer Stories
Swisscom, the Swiss telecom, is going into the cloud business. Its subsidiary Swisscom IT Services AG has signed up with Red Hat as a Certified Cloud Provider and launched a public cloud Infrastructure-as-a-Service (IaaS) cloud targeting enterprise-class customers primarily in ...
Apache Deltacloud, the Red Hat-contributed ReSTful API that abstracts differences between clouds so services on any cloud can be managed – provided of course there’s a driver – has graduated from the Apache Foundation’s incubator and is now a full-fledged Top-Level Project (TLP)....
In a surprise move on Tuesday, January 10, Oracle wheeled out its Big Data Appliance. That’s the one it said in October would be ready sometime in the first half. Only nobody believed it meant early in the first half. Heck, it’s not even clear anybody thought Oracle could make ...
Rackspace Hosting, the service leader in cloud computing, on Thursday announced its acquisition of SharePoint911, an industry leader in SharePoint consulting, training, and "JumpStart" services within SharePoint. The unification of both companies provides capabilities to deliver ...
CloudLinux, Inc., on Thursday released CafeFS 3, a virtualized file system for shared hosters that cages each customer within its own virtualized file system. CageFS becomes part of CloudLinux OS at no additional charge. CloudLinux OS, the only commercially-supported Linux OS m...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON Featured Whitepapers
ADS BY GOOGLE

Breaking Cloud Computing News

The Khronos™ Group, an industry consortium creating open standards for the accelera...