2

I am trying to add a watermark to a PDF with a PNG file that has a transparent background.

Every time I create the watermark it comes out as black background. When it comes to using a PDF as the watermark I get a white background of the watermark. Also, the PDF watermark when turned into thumbnails becomes grayscale.

What is causing this? And what can I do to allow transparency?

I am using ColdFusion 11.

Here is the code for both:

Watermark by PNG:

<cfpdf
 action="addwatermark"
 foreground="true"
 opacity="6"
 source="PDFS/blankpage.pdf"
 destination="PDFS/watermarked/blankpage.pdf"
 image="PDFS/samplemusicpage2.png"
 overwrite="yes"
>

<cfpdf
 action="thumbnail"
 resolution="low"
 source="PDFS/watermarked/blankpage.pdf"
 destination="PDFS/_thumbnails"
 imageprefix="blankpage"
 overwrite="yes"
 scale="40"
>

Here is the code for using a PDF as a watermark:

<cfpdf
 action="addwatermark"
 foreground="true"
 opacity="6"
 source="PDFS/blankpage.pdf"
 destination="PDFS/watermarked/blankpage.pdf"
 copyfrom="PDFS/samplemusicpage.pdf"
 overwrite="yes"
>
<cfpdf
 action="thumbnail"
 resolution="low"
 source="PDFS/watermarked/blankpage.pdf"
 destination="PDFS/_thumbnails"
 imageprefix="blankpage"
 overwrite="yes"
 scale="40"
>

Here are the images that I am working with in this example: Here is the PNG File: PNG File

Here is the Read PDF File:PDF FIle

Will
  • 70
  • 9
  • *"I have images of how the thumbnails are coming out but I need 10 rep to post pictures."* -- Can you post links to the images? Someone with enough reputation could then insert them into your question... – Kurt Pfeifle May 01 '15 at 17:19
  • I cannot test it out now, but it sounds similar to issues I remember having with CF9. Might want to a) check the bug database b) try it with another version to see if it produces the expected results. – Leigh May 01 '15 at 19:16
  • @KurtPfeifle I have posted the images. I have gained enough rep in order to do that. – Will May 04 '15 at 13:29

1 Answers1

0

I found a fix to my own issue. The best way that I found to accomplish this was to created the PDF's into images and then use Coldfusion's imaging to add the watermark to the images.

<cfloop query="jpgfiles">
<cfset theFile = directory & "/" & name>
<cfset imgFile = imageRead(theFile)>
<cfset imgInfo = imageInfo(imgFile)>
<cfset imagepaste(imgFile, watermark, imgInfo.width-watermarkinfo.width, imgInfo.height-watermarkinfo.height)>
<cfset imageWrite(imgFile, processedfolder & "/" & name, true)>
</cfloop>

Some of the terms are my variables, but the point is I no longer have the black background on the images like the above.

Will
  • 70
  • 9