|
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
Architecture Handling PDF Forms with ColdFusion
A cost-efficient alternative to Adobe's enterprise PDF server
By: Tim Burton
Aug. 17, 2005 09:15 AM
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.
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
Create the PDF Form
Handle the Form: ColdFusion coding 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 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. Reader Feedback: Page 1 of 1
Your Feedback
Latest Cloud Developer Stories
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week
Breaking Cloud Computing News
|
||||||||||||||||||||||||||||||||||||||||||||||||||||