|
ColdFusion 9.0 Resources |
Using the Duplicate function to create versions of a PDF documentYou can use the Duplicate function to clone PDF variables, which is an efficient way to create different versions of a PDF document from a single source file. For example, you can customize PDF output based on your audience by creating clones of a PDF variable and performing different actions on each clone. The following example shows how to create a clone of a PDF document in memory, and create one version of the document with a watermark and another version of the document where permissions are restricted: <cfset filename="coldfusion.pdf">
<!--- This code reads a PDF document into a PDF variable called pdfVar1.
--->
<cfpdf action="read" source="#filename#" name="pdfVar1">
<!--- This code uses the Duplicate function to create a clone of pdfVar1 called pdfVar2. --->
<cfset pdfVar2=Duplicate(pdfVar1)>
<!--- This code creates a watermarked version of the source PDF document from the pdfVar1
variable. --->
<cfpdf action="addwatermark" source="pdfVar1" rotation="45" image="watermark.jpg"
destination="watermark_coldfusion.pdf" overwrite="yes">
<!--- This code creates a protected version of the source PDF document from the pdfVar2
variable. --->
<cfpdf action=protect source="pdfVar2" encrypt="RC4_128" permissions="none"
newownerpassword="owner1" destination="restricted_coldfusion.pdf" overwrite="yes">
|