Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 940

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
<!--- Create a blank image that is 500 pixels square. --->
<cfset myImage=ImageNew("",500,500)>
<!--- Set the background color for the image to white. --->
<cfset ImageSetBackgroundColor(myImage,"white")>
<!---Clear the rectangle specified on myImage and apply the background color. --->
<cfset ImageClearRect(myImage,0,0,500,500)>
<!--- Turn on antialiasing. --->
<cfset ImageSetAntialiasing(myImage)>
<!--- Draw the text. --->
<cfset attr=StructNew()>
<cfset attr.size=50>
<cfset attr.style="bold">
<cfset attr.font="Verdana">
<cfset ImageSetDrawingColor(myImage,"blue")>
<cfset ImageDrawText(myImage,"PROOF",100,250,attr)>
<!--- Write the text image to a file. --->
<cfimage action="write" source="#myImage#" destination="text.tiff" overwrite ="yes">
<!--- Use the text image as a watermark in the PDF document. --->
<cfpdf action="addwatermark" source="c:/book/1.pdf" image="text.tiff"
destination="watermarked.pdf" overwrite="yes">
For more information on ColdFusion images, see
an example of using DDX elements to create a text-string watermark, see
page 949.
Using a PDF page as a watermark
Use the
attribute to create a watermark from the first page of a PDF file and apply it to another PDF
copyFrom
document. In the following example, ColdFusion creates a watermark from the first page of image.PDF, applies the
watermark to the second page of artBook.pdf, and writes the output to a new file called output.pdf:
<cfpdf action="addWatermark" copyFrom="image.pdf" source="artBook.pdf" pages="2"
destination="output.pdf" overwrite="yes">
In this example, image.pdf appears in the background of the second page of artBook.pdf. ColdFusion does not change
the size of the watermark image to fit the page. The page used as a watermark can contain text, graphics, or both.
Removing watermarks
Use the
action to remove a watermark from one or more pages in a PDF document. The following
removeWatermark
example shows how to remove a watermark from the entire PDF document and write the document to a new output file:
<cfpdf action="removeWatermark" source="artBook.pdf" destination="noWatermark.pdf">
The following example shows how to remove a watermark from the first two pages of a PDF document and overwrite
the source document:
<cfpdf action="removeWatermark" source="artBook.pdf" destination="artBook.pdf"
overwrite="yes" pages="1-2">
Because the source and the destination are the same and the
the source file with the output file.
"Creating and Manipulating ColdFusion
attribute is set to
overwrite
Last updated 1/20/2012
Images" on page 959. For
"Adding text-string
watermarks" on
, ColdFusion overwrites
yes
935

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents