2

I've learned how to add a watermark to a pdf.

<cfpdf action="addwatermark" image="NoteToSelf.png" 
    pages="1" 
    position="0,0" 
    showOnPrint="no"
    source="my.pdf" 
    destination="#myDir#\new.pdf" 
    overwrite="yes"
    opacity="10">

The way I read it, the watermark has to be an image. But NoteToSelf.png needs to be text that I've read from a database.

Q: How can I add text as a watermark?

Q: If I am required to use an image for the watermark, then how do I use the ImageNew tag to create an image of text?

Peter Boughton
  • 110,170
  • 32
  • 120
  • 176
Phillip Senn
  • 46,771
  • 90
  • 257
  • 373

1 Answers1

6

ColdFusion 8.0.1 onwards you can supply text directly to the cfpdf tag:

<cfpdf action="addwatermark" position="10,10" text="I am the watermakr" source="pdfContent" rotation="90" foreground="yes">

If you are not on on 8.0.1 then you would need to use imageNew and the image write text functions and pass that in.

Sam Farmer
  • 4,108
  • 17
  • 20
  • Thanks Sam! It's amazing what you can do with 1 line of code in ColdFusion! – Phillip Senn Jun 25 '10 at 15:51
  • 1
    Thx Sam- this is NOT in the current docs, and "text" is NOT an attribute of cfpdf in current online docs. But finding this saved my bacon. – j-p Oct 30 '14 at 15:50