You can use the ImageDrawText function to create a text image in ColdFusion and apply the image as a watermark, as the following example shows:
<!--- 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 Creating and Manipulating ColdFusion Images. For an example of using DDX elements to create a text-string watermark, see Adding text-string watermarks.