Home > ColdFusion > ColdFusion: Creating Print Only Watermarks

ColdFusion: Creating Print Only Watermarks

While <cfpdf> supports watermarks that are visible on screen, but invisible when printing, the reverse does not seem to be supported.  At least not as far as I can tell.  However, with a bit of DDX you can create invisible watermarks.  Using the <Watermark> element and its showOnScreen and showWhenPrinting attributes, you can create watermark’s that are only visible when printed.

Cracker - I Hate My Generation

Cracker - I Hate My Generation

Code:

<cfsavecontent variable="ddxText">
<?xml version="1.0" encoding="UTF-8"?>
<DDX xmlns="http://ns.adobe.com/DDX/1.0/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ns.adobe.com/DDX/1.0/ coldfusion_ddx.xsd">
<PDF result="TargetPdf">
<PDF source="SourcePdf">
<Watermark showOnScreen="false" showWhenPrinting="true" opacity="95%">
<StyledText>
<p font-size="49pt" font-weight="bold" color="#99001A" font="Algerian">
I Hate My Generation
</p>
</StyledText>
</Watermark>
</PDF>
</PDF>
</DDX>
</cfsavecontent>

<cfif IsDDX( ddxText )>
<cfset input.SourcePdf  = ExpandPath("./cracker.pdf") />
<cfset output.TargetPdf = ExpandPath("./invisibleWatermark.pdf") />

<cfpdf action="processDDX"
    ddxfile="#ddxText#"
    inputFiles="#input#"
    outputFiles="#output#"
    name="ddxResult" />

    <cfdump var="#ddxResult#" />
<cfelse>
    Invalid DDX String
</cfif>
Advertisements
Categories: ColdFusion Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: