Title: Creating a Dynamic Adobe PDF Using ColdFusion
1Creating a Dynamic Adobe PDF - Using ColdFusion
- Randy Brown
- brownra_at_msu.edu
- Michigan State Univerisity
- University Development
2What You Will Need
- Adobe Acrobat v5.0 (v4.0 or v3.0 will work)
- Cold Fusion Studio or Text Editor (notepad)
- Cold Fusion Application Server
3What The Client Will Need
- Acrobat 5.0 Reader (This will work with v3.0 or
v4.0)
- Acrobat Plug-In Compatible Browser (Preferably IE
v5.0 or greater)
4FIRST STEPYou will need to create a PDF document
5Create a PDF Document
Step 1. Create a PDF Document using Adobe
Acrobat from any Windows application by selecting
the PDFWriter as your output device
Step 2. Print/Save PDF to the Web Server.
6NEXT STEP You will need to create a PDF form
7Create a PDF Form
Step 1. Use the existing PDF created.
Step 2. Insert Form Fields using Adobe Acrobat
Step 3 . Re-save PDF to Web Server.
8Things to remember when Creating a PDF Form
- Always give form fields a name
- Do not use spaces in name
- Always set the font and size
- The border is optional but good to have
9NEXT STEP Now you have a PDF form, how does it
work with a Web Server?
10What happens when a Client request a PDF?
Client Requests PDF Doc
Client Receives PDF Doc
No magic here, the server handles
this request similar to a standard
html request.
Server Receives PDF Doc Request
Server Sends PDF Doc
11NEXT STEP How do you create the data file (FDF)
to populate the PDF fields?
- A FDF file is a standard DOS/ASCII file
- This file holds all the data that will be merged
with PDF form fields
- Most importantly it holds the /F switch
information
12Create a FDF File
Step 1. Create a FDF file This can be accompli
shed with CF Studio, a text editor or more advanc
ed with a CFM.
Step 2. Save as filename.fdf to the Web Server
13NEXT STEP We are going to take a closer look at
the base components and syntax of a FDF file?
14Form Data File (FDF)
PDF-1.2 1 0 obj FDF File Header
15Form Data File (FDF)
PDF-1.2 1 0 obj
Anywhere) /V(East Lansing, MI 48823)
Body (Field Definitions)
16Form Data File (FDF)
PDF-1.2 1 0 obj
Anywhere) /V(East Lansing, MI 488233) /F(reg
istration.pdf)
PDF Filename
17Form Data File (FDF)
/FDF /V(Purple Place) ) /V(123 Anywhere) StateZip) /V(East Lansing, MI 48823)
/F(registration.pdf) endobj tra
iler EOF
FDF File Footer
18NEXT STEP Now you have a FDF file, how does it
works with a PDF and the Web Server?
19What happens when a Client request a FDF file?
Client Requests FDF Doc
Client Receives FDF Doc
No magic here, the server handles
this request similar to a standard
html request.
Server Receives FDF Doc Request
Server Sends FDF Doc
Note FDF file has been created and saved on se
rver
already.
20Overview of how the FDF file works with a PDF
Form
Client Requests Specified PDF Doc
Client Receives Merges PDF Doc w/ FDF file
- After receiving FDF file from Server, the browser
(per the Adobe Acrobat Reader) requests the PDF
form specified in the /F line
- Once received, the PDF is merged with the FDF
file to create a final document
- Hint This is the magic -).
Server Receives PDF Doc Request
Server Sends PDF Doc
21NEXT STEP Now you understand the MAGIC of how
the PDF and FDF work together. Lets review how
ColdFusion handles a file request and how it fits
into this puzzle.
22Overview of the ColdFusion file request system
Client Requests CFM File
Client Receives CFAS HTML Response
- Web Server passes CFM page request to CFAS.
- CFAS processes and returns (typically) HTML
response.
- Web Server passes on what appears to be a file
Server Receives CFM File Request
Server Sends CFAS HTML Response
Web Server sends CFM file to CFAS for Processing
CFAS sends back to web server an HTML formatted
response
23ColdFusion FDF Integration
Client Receives CFAS FDF Response
Client Requests CFM File
- Web Server passes CFM page request to CFAS.
- CFAS processes and returns FDF response instead.
Server Receives CFM File Request
Server Sends CFAS FDF Response
Web Server sends CFM file to CFAS for Processing
Web Server passes on what appears to be an FDF
file
CFAS sends back to web server an FDF formatted
response
24Overview of how the FDF file works with a PDF
Form(again)
Client Requests Specified PDF Doc
Client Receives Merges PDF Doc w/ FDF file
- After receiving FDF file from Server, the browser
(per the Adobe Acrobat Reader) requests the PDF
form specified in the /F line
- Once received, the PDF is merged with the FDF
file to create a final document
Server Receives PDF Doc Request
Server Sends PDF Doc
25LAST STEPHow do we automate this process using
ColdFusion
26How to create the code to make a FDF on the fly
showdebugoutput"No" n/vnd.fdf" FDF-1.2 1 0 obj FDF /V(Purple Place) other fields
/F(registration.pdf) endobj tr
ailer EOF
27How to add a Query to pull data from a database
SELECT FROM tblPeople WHERE PersonID k
id cfsetting enablecfoutputonly"Yes
" showdebugoutput"No" ion/vnd.fdf" FDF-1.2 1 0 obj /FDF /V(myQuery.Company) dress) /V(myQuery.Address)
28Additional Resources
- www.adobe.com
- www.planetpdf.com
- www.peakforms.com
- www.pdfzone.com