Skip to main content
Participating Frequently
August 16, 2011
Answered

PDFs - Watermarking & Locking Content

  • August 16, 2011
  • 1 reply
  • 2145 views

Running:

  • Windows Server 2003 R2
  • Coldfusion 9 (Developer Edition currently)
  • IIS v6.0
  • MySQL

I have 2 questions regarding PDFs.

1) Will the watermarking not work in developer edition because of the Adobe watermark that is already there or am I doing it wrong?

<cfpdf action="addwatermark" source="reports/#FileName#" image="text.tiff"

    destination="c:\Inetpub\wwwroot\admin\reports\#FileName#" overwrite="yes">

2) Is there any way to lock down a PDF file? I'm writing tables of text and I want to make it so users can't select the text, is this possible?

    This topic has been closed for replies.
    Correct answer -__cfSearching__-

    You were right, the watermarking does work. I tried it with a gigantic image and it only shows around the edges of the page. The Coldfusion Developer Edition watermark is a large white rectangle that takes almost all the page, and adding a watermark places it under the existing watermark.

    EDIT:

    Using foreground="yes" lets you show the watermark on top of the Adobe watermark.


    The Coldfusion Developer Edition watermark is a large

    white rectangle

    Oh yeah, I forgot about the big white rectangle issues Any difference if you use foreground=true?

    1 reply

    Inspiring
    August 17, 2011

    source="reports/#FileName#" image="text.tiff"

    No, it works even under the developer edition. Perhaps one of your paths is off?=. Have you tried using absolute file paths?

    2) Is there any way to lock down a PDF file? I'm writing

    tables of text and I want to make it so users can't select

    the text, is this possible?

    Cfpdf allows you to disable certain features like copying by using action="protect". See the "permissions" section of the documentation for a complete listing. Just keep in mind these settings are not bullet proof. A determined user can find a way around such restrictions.

    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7995.html

    Kastion2KAuthor
    Participating Frequently
    August 17, 2011

    Thanks for the help, the link you provided answered all the questions I had concerning PDF protections.

    I am still having problems with the watermarking. I used absolute pathing and still no dice. Here's the code I'm using, that I took a snippet of from a tutorial I can't find at the moment.

    <cffile action="write" output="#HOLPDF#" file="c:\Inetpub\wwwroot\admin\reports\#FileName#">

    <!--- Create a blank image that is 500 pixels square. --->

    <cfset myImage=ImageNew("",500,500)>

    <!--- Set the background color for the image to white. --->

    <cfset ImageSetBackgroundColor(myImage,"white")>

    <!---Clear the rectangle specified on myImage and apply the background color. --->

    <cfset ImageClearRect(myImage,0,0,500,500)>

    <!--- Turn on antialiasing. --->

    <cfset ImageSetAntialiasing(myImage)>

    <!--- Draw the text. --->

    <cfset attr=StructNew()>

    <cfset attr.size=50>

    <cfset attr.style="bold">

    <cfset attr.font="Verdana">

    <cfset ImageSetDrawingColor(myImage,"blue")>

    <cfset ImageDrawText(myImage,"IPSUMDIPSUM",100,250,attr)>

    <!--- Write the text image to a file. --->

    <cfimage action="write" source="#myImage#" destination="text.tiff" overwrite ="yes">

    <!--- Use the text image as a watermark in the PDF document. --->

    <cfpdf action="addwatermark" source="c:\Inetpub\wwwroot\admin\reports\#FileName#" image="c:\Inetpub\wwwroot\admin\text.tiff"

        destination="c:\Inetpub\wwwroot\admin\reports\#FileName#" overwrite="yes">

    Kastion2KAuthor
    Participating Frequently
    August 17, 2011

    You were right, the watermarking does work. I tried it with a gigantic image and it only shows around the edges of the page. The Coldfusion Developer Edition watermark is a large white rectangle that takes almost all the page, and adding a watermark places it under the existing watermark.

    EDIT:

    Using foreground="yes" lets you show the watermark on top of the Adobe watermark.