Create Files on the Fly in ColdFusion
page 2 of 6
by Sarita Mishra
Feedback
Average Rating: 
Views (Total / Last 10 Days): 33535/ 113

Creating PDF files

To populate a PDF file we need to have some requirements in our system, such as Coldfusion or Adobe Acrobat full version.

These systems requirement some steps to be followed to populate PDF files from ColdFusion.

Create a PDF document to populate

Create a document using either Microsoft Word or html.  Adobe Acrobat must be there to create a PDF for that document.  Save it in WebServer .

Insert required fields using Acrobat

Open the PDF in Acrobat and insert the fields using the menubar Tools, like Form Tool, to create text fields.  Then give a name to each field, a font size and a style.  The name of each field corresponds to the data given as an input. Use the Text Tool to edit the text fields of fonts, size, etc.  Save it and place it in the WebServer.

Create a ColdFusion page to populate PDF

Now open any text editor and create a document; save it as .cfm extension.  Create a coldfusion form to collect data from the fields over internet or using database query.  This page will act as the way to populate the PDF file.

Below we have the code for a FDF file.FDF (Form Data File) which contains all the data to be merged with PDF.

Listing 1     

(The CFM codes for Input)
<FORM ACTION="output.cfm" METHOD="POST" ENABLECAB="YES">
      <P><B>First Name</B>
      <INPUT TYPE="TEXT" NAME="fname"></P>
      <P><B>Last Name</B>
      <INPUT TYPE="TEXT" NAME="lname"></P>
      <P><INPUT TYPE="SUBMIT" VALUE="Submit"></P>
</FORM>
(The Output Codes)

 <CFSETTING ENABLECFOUTPUTONLY="YES" SHOWDEBUGOUTPUT="NO">
 <CFCONTENT TYPE="APPLICATION/vnd.fdf">
 <CFOUTPUT>
%FDF-1.2                            --------- Header of FDF 
 1 0 obj <<
 /FDF <<
 /Fields                  -----------FDF body
 [
 <<
 /T(date)
 /V(#date#)
 >>
 <<
 /T(fname)
 /V(#form.fname#)
 >>
 <<
 /T(lname)
 /V(#form.lname#)
 >>
 ]
 /F(http://www.yoursite.com/pdf/file_name.pdf)      ------- The path of the PDF file
 >>
 >>
 endobj
 trailer -------- FDF footer   
 <</Root 1 0 R>>
 %%EOF
</CFOUTPUT>

Run the file and enter the required field to see the PDF file given in /F tag.


View Entire Article

User Comments

Title: great   
Name: Sandy
Date: 2006-11-02 6:33:11 AM
Comment:
Great job.. keep moving ahead
Title: Kar   
Name: Chandrakanta
Date: 2006-11-01 2:56:09 AM
Comment:
It is very nice and can also helpful for the new developers. Come across creating different file formats at the time of requirement.
Title: Great Job   
Name: pd
Date: 2006-11-01 2:41:58 AM
Comment:
Keep it up.
Title: Nice Article   
Name: Tom Anderson
Date: 2006-10-31 1:46:13 AM
Comment:
Very Nice and informative article for people working on ColdFusion.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-10-09 3:30:44 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search