anatp_123
anatp_123

Reputation: 1205

Add a watermark Image to PDF attachment

I have a link that creates a pdf attachment.

<a href="filename.cfm?id=#id#" target="_blank">create pdf attachment</a>

It create a attached pdf and I would like to add a watermark image in the middle of the pdf? filename.cfm file

<cfsetting enablecfoutputonly="true">
<cfcontent type="application/pdf">
<cfheader name="Content-Disposition" value="attachment;filename=nameoffile.pdf">

<cfdocument format="PDF" localurl="yes"
  marginTop="0.1" marginLeft="0.2" marginRight="0.2" marginBottom="0.1"
  pageType="custom" pageWidth="8.5" pageHeight="10.2">

  ...pdf content...
</cfdocument>

Upvotes: 0

Views: 722

Answers (1)

Miguel-F
Miguel-F

Reputation: 13548

Have you looked at using the cfpdf tag? One of it's options is to add watermarks to PDF documents.

From the docs here:

Add a watermark to a PDF document 

<cfpdf
required: 
    action = "addwatermark"
    source = "absolute or relative pathname to a PDF file|PDF document variable|cfdocument variable" 
one of the following: 
    copyfrom = "absolute or relative pathname to a PDF file from which the first page is used as a watermark" 
    image = "absolute or relative pathname to image file|image variable used as a watermark" 
optional:
    foreground = "yes|no"
    isBase64 = "yes|no"
    opacity = "watermark opacity"
    overwrite = "yes|no"
    pages = "page or pages to add the watermark"
    password = "user or owner password for the PDF source file"
    position = "position on the page where the watermark is placed"
    rotation = "degree of rotation of the watermark"
    showonprint = "yes|no"> 

Notice that the source attribute can be a cfdocument variable.

Upvotes: 1

Related Questions