Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 949

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Working with Documents, Charts, and Reports
<!--- The following code verifies that the DDX file exists and the DDX instructions are
valid. --->
<cfif IsDDX("merge.ddx")>
To implement the DDX instructions in ColdFusion, you create two structures: an input structure that maps the DDX
input instructions to the PDF source files, and an output structure that maps the DDX output instructions to a PDF
output file,
The following code maps two files called Chap1.pdf and Chap2.pdf to the Doc1 and Doc2 sources that you defined in
the DDX file:
<!--- This code creates a structure for the input files. --->
<cfset inputStruct=StructNew()>
<cfset inputStruct.Doc1="Chap1.pdf">
<cfset inputStruct.Doc2="Chap2.pdf">
The following code maps the output file called twoChaps.pdf to the Out1 result instruction that you defined in the
DDX file:
<!--- This code creates a structure for the output file. --->
<cfset outputStruct=StructNew()>
<cfset outputStruct.Out1="twoChaps.pdf">
To process the DDX instructions, you use the
file, the input structure, and the output structure, as the following example shows:
<cfpdf action="processddx" ddxfile="merge.ddx" inputfiles="#inputStruct#"
outputfiles="#outputStruct#" name="myBook">
The
attribute creates a variable that you can use to test the success or failure of the action. If the action is
name
successful, ColdFusion generates an output file with the name and location specified in the output structure. The
following code returns a structure that displays a success, reason for failure, or failure message (if the reason is
unknown) for each output file, depending on the result:
<cfdump var="#myBook#">
The previous example performs the same task as the
<cfpdf action="merge" destination="twoChaps.pdf" overwrite="yes">
<cfpdfparam source="Chap1.pdf">
<cfpdfparam source="Chap2.pdf">
</cfpdf>
</cfif>
In this situation, it makes more sense to use the
perform tasks that you can't perform with other actions in the
elements.
Adding a table of contents
You use DDX instructions to add a generated table of contents page to the PDF output file. Generating a table of
contents is useful if you are assembling documents from multiple sources. You can generate a table of contents that
contains active links to pages in the assembled PDF document. The following code shows how to create DDX
instructions to merge two documents and add a table of contents:
action of the
processddx
action in ColdFusion, as the following example shows:
merge
action because it is easier. DDX is useful when you have to
merge
tag, or you require more control over specific
cfpdf
Last updated 1/20/2012
tag, in which you reference the DDX
cfpdf
944

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents