
932
DEVELOPING
COLDFUSION 9 APPLICATIONS
Working with Documents, Charts, and Reports
Las
t
upda
te
d 8/5/2010
Using shortcuts for common tasks
You use the
cfpdf
tag actions to perform shortcuts to common PDF document assembly and manipulation.
Adding and removing watermark images
Use the
addWatermark
and
removeWatermark
actions to add and remove watermarks from PDF documents. You can
create a watermark and apply it to a PDF document in one of the following ways:
•
Use an image file as a watermark.
•
Specify a variable that contains an image file.
•
Specify a ColdFusion image.
•
Use the first page of a PDF document as a watermark.
Note:
You can also use the
Watermark
or
Background
DDX elements with the
processddx
action to create a text-string
watermark. For more information, see “
Using DDX to perform advanced tasks
” on page
943.
Using an image file as a watermark
The following example shows how to specify an image file as a watermark:
<cfpdf action="addWatermark" source="artBook.pdf"
image="../cfdocs/images/artgallery/raquel05.jpg" destination="output.pdf"
overwrite="yes">
By default, ColdFusion centers the image on the page, sets the opacity of the image to 3 out of 10 (opaque), and displays
the image in the background of each page in the output file. In the following example, ColdFusion displays the
watermark in the foreground, offset 100 pixels from the left margin of the page and 100 pixels from the bottom margin
of the page. Because the opacity is set to 1, the image does not obscure the page content.
<cfpdf action="addWatermark" source="artBook.pdf"
image="../cfdocs/images/artgallery/raquel05.jpg" destination="output.pdf"
overwrite="yes" foreground="yes" opacity=1 showOnPrint="no" position="100,100">
For a complete list of attributes and settings, see the cfpdf tag in the
CFML Reference
.
With the ColdFusion 9 release, the
addWatermark
action now supports the
rgb
and
argb
formats also. The following
example shows that if you set the parameters for a new image to rgb or argb and then use the cfpdf
action=addwatermark, ColdFusion allows this action:
<!---setting the argb format for myImage--->
<cfset myImage = ImageNew("",200,200,"argb","gray")>
<!---adding watermark for myImage--->
<cfpdf action="addwatermark" rotation="45" foreground="true" image="#myImage#"
source="RemoveArts.pdf" destination="dest.pdf" overwrite="yes">
Password-protect PDF documents
cfpdf action="protect" newUserPassword
="
xxxx
"
Set the initial view for a PDF document
cfpdf action="processddx"
with the
InitialViewProfile
DDX
element
Create different versions of a PDF document
Duplicate
function to clone PDF variables
Task
Action
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...