
941
DEVELOPING
COLDFUSION 9 APPLICATIONS
Working with Documents, Charts, and Reports
Las
t
upda
te
d 8/5/2010
Creating PDF Portfolios
You can now create PDF packages using the
package = "true"
attribute with the
merge
action:
<cfpdf action="merge" package="yes" destination="./myBook/adobetest.pdf" overwrite="yes">
<cfpdfparam source="./inputFiles/c.zip" >
<cfpdfparam source="./inputFiles/d.jpg" >
<cfpdfparam source="./inputFiles/a.pdf" >
<cfpdfparam source="./inputFiles/z.txt" >
<cfpdfparam source="./inputFiles/MSTribute.pps" >
<cfpdfparam source="./inputFiles/Test1.docx" >
<cfpdfparam source="./inputFiles/NewMovie.mp3" >
<cfpdfparam source="./inputFiles/testserver.air" >
<cfpdfparam source="./inputFiles/123.xml" >
<cfpdfparam source="./inputFiles/New_test_case.xls" >
</cfpdf>
Flattening forms created in Acrobat
Flattening forms involves removing the interactivity from the form fields. This action is useful for displaying form data
and presenting it without allowing it to be altered. Use the
write
action to flatten PDF forms, as the following example
shows:
<cfpdf action="write" flatten="yes" source="taxForms\f1040.pdf"
destination="taxforms/flatForm.pdf" overwrite="yes">
<a href="http://localhost:8500/Lion/taxforms/flatForm.pdf">1040 form</a>
Note:
If you flatten a prefilled form created in Acrobat, ColdFusion flattens the form and removes the data from the form
fields. When you specify a form created in Acrobat as a source file for
merge
action of the
cfpdf
tag, ColdFusion
automatically flattens the form and removes data from the form fields, if the fields are filled in. ColdFusion does not
support flattening forms created in LiveCycle.
Linearizing PDF documents for faster web display
For efficient access of PDF files over the web, linearize PDF documents. A linearized PDF file is structured in a way
that displays the first page of the PDF file in the browser before the entire file is downloaded from the web server. As
a result linear PDF documents open almost instantly.
To linearize PDF documents, specify the
saveOption
attribute of the
write
action. The following example saves the
output file in linear format:
<cfpdf action="write" saveOption="linear" source="myBook.pdf" destination="fastBook.pdf"
overwrite="yes">
Note:
Linearization can decrease performance when handling large documents.
Generating thumbnail images from PDF pages
Use the
thumbnail
action to generate thumbnail images from PDF pages. If you specify only the
source
attribute with
the thumbnail action, ColdFusion automatically creates a directory relative to the CFM page called thumbnails where
it stores a generated JPEG image for each page in the document. The filenames are in the following format:
PDFdocumentName_page_n.JPG
For example, assume that the source file in the following example has 100 pages:
<cfpdf action="thumbnail" source="myBook.pdf">
ColdFusion generates the following files and stores them in the thumbnails directory: