Archive

Archive for August, 2011

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