将水印图像添​​加到PDF附件

时间:2017-05-18 16:28:39

标签: coldfusion

我有一个创建pdf附件的链接。

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

它创建了附加的pdf,我想在pdf中间添加水印图像? filename.cfm文件

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

1 个答案:

答案 0 :(得分:1)

您是否看过使用cfpdf标签?其中一个选项是为PDF文档添加水印。

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"> 

请注意,source属性可以是cfdocument变量。