Converting a ColdFusion Form to a PDF File - Succeed in ColdFusion Development: School for Champions

The School for Champions is an educational website that shows you how to achieve your dreams.

School for Champions

SfC Home > ColdFusion >

Explanation of how to convert a form developed in ColdFusion to an Adobe Acrobat PDF format. Also refer to Macromedia, Allaire, markup language, database, query, SQL, output, code, Ron Kurtus, School for Champions. Copyright © Restrictions

Simple Method to Populate a PDF File with ColdFusion

by Ron Kurtus (5 January 2003)

You can add simple Adobe Acrobat code to a Macromedia ColdFusion page that will populate a PDF file with values sent from submitting a form.

Populating a PDF File from ColdFusion explains various applications and provides the basic steps to acheive this task.

This lesson will answer those questions. There is a mini-quiz near the end of the lesson.

Example

Enter information below, click Submit, and see the resulting PDF file. Backspace to return to this page.

First Name

Last Name

Coding

It is assumed that you have created a PDF file in Acrobat and used the Form Tool to create the text fields, which are date, fname and lname in our example.

Input

The CFML code for your input is:

<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>

Output

The output code is:

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

Notes

You could also use <CFIF IsDefined("form.submit")> to include the input and output in one page.

Also, some people may get a warning that the file_name.fdf file may not be safe, depending on their security settings. You need to provide an assurance in case this happens.

Summary

You can convert and send a ColdFusion form as a PDF file using activePDF Toolkit. You simply make a PDF form, create the ColdFusion form, install the activePDF server, and create a ColdFusion page to populate the PDF.

Answers to Readers' Questions


Spread your knowledge


Resources

The following resources provide information on this subject.

Websites

ColdFusion Resources

Books

Top-rated books on ColdFusion

Miscellaneous


Mini-quiz to check your understanding

1. What is ColdFusion Studio?

An image tool studio-quality pictures for the Web

An add-on to generate custom tags

A mark-up editor for building Web sites

2. What is needed to display ColdFusion pages on the Web?

Users must own ColdFusion

A ColdFusion server is needed

HTML

3. What is a major application of ColdFusion?

Dynamic, data-driven pages

Animation databases

Sites that cannot be hacked

If you got all three correct, you are on your way to becoming a Champion in ColdFusion Development. If you had problems, you had better look over the material again.


Resources

Adobe Acrobat - Area in Adobe site, explaining their Acrobat product

activePDF - Company that sells the activePDF Toolkit needed to convert CF to PDF format


What do you think?

Do you have any questions, comments, or opinions on this subject? If so, send an email with your feedback. We will try to get back to you as soon as possible.


Share link

Feel free to establish a link from your website to pages in this site.

Or use our form to send this link to yourself or a friend.


Students and researchers

The Web address of this page is
www.school-for-champions.com/coldfusion/cftopdf.htm.

Please include it as a reference in your report, document, or thesis.


Where can you go from here?

School for Champions

ColdFusion topics

Converting a ColdFusion Form to a PDF File

The School for Champions helps you become the type of person that can be can be called a Champion.