Helpful Information
 
 
Category: ColdFusion
CFPDF Addwatermark using Text, change font size?

I've been having lots of fun with trying to get a watermark to behave the way I want it to using CFPDF. I first tried an image...which looked bad, and caused printing issues with certain printer drivers. Then I tried using the new Text="Your Watermark text" property in a <CFPDF Action="addwatermark"> tag, and I have everything working almost perfectly except that I cannot for the life of me find out how to change the font size. Here's the code:


<cfsavecontent variable="myWatermark">
<body style="font-size:30pt;font-family:Arial;">
<p>Watermark Text</p>
</body>
</cfsavecontent>

<cfpdf
action = "addwatermark"
source = "strFile"
text = "#myWatermark#"
foreground = "yes"
rotation = "45"
opacity = "2"
showonprint = "yes"
name = "strFile"
>

The watermark comes out in Arial font at the desired angle and opacity, but it completely ignores the font-size:30pt; and I've tried placing that style attribute within the <p> tag as well as wrapping the text in a <font size='2'> tag, and nothing works. I even get errors when I try to use a plain <font> tag. I've tried using DDX and got the results I am after, but I dislike having to generate files, and would like to keep using a PDF variable if possible (which DDX doesn't seem to support).

Anyone have any ideas?

Thanks!

Toby

You can try using the 'height' and 'width' attributes which is used to make bounding box for the watermark. playing with different height and width values you will see the font-size change.










privacy (GDPR)