coldfusioncoldfusion-8cfpdfcfimage

Adding a text watermark


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?


Solution

  • 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.