CFPDF addWatermark not respecting vector art

Is it possible to add watermarks and preserve vector artwork?

When using addWatermark and sourcing from other pdf (containing vector art), the watermark artwork is added as pixel based images.
Resulting PDFs… Left is Lucee, Right is ACF9
lucee-vs-acf9


Details
This is (hopefully) our last hurdle porting ACF9 to Lucee…
The app uses data to build a PDF certificate based on

  1. the company issuing the certificate
  2. the authorised signatory of the qualification and
  3. the student data.

Points 1 and 2 are achieved by addWatermark where the watermark being added is a pdf containing vector artwork of the company branding and another pdf containing vector art of the signature.

Simplified look at the code…

// The initial creation of the document (in memory) of the student's data (html) 
<cfdocument 
	name="variables.createdPDF"
	format="PDF"
	overwrite="yes"
	fontembed="no"
	marginbottom="0"
	marginleft="1.3"
	marginright="1.3"
	margintop="#variables.certificate_struct.page_margin_top#"
	unit="cm"
	pagetype="A4"
	scale="100"
	backgroundvisible="no"
	orientation="#variables.certificate_struct.page_orientation#"
	>#variables.certificate_struct.certificate_HTML#
</cfdocument>

Some lookups to get brand template and signature template which are put into an array, then looped over to alter the pdf.
Here is an example of the templates array…
lucee-vs-acf9-temnplate-array

<cfif arrayLen(variables.baseTemplateArray) GT 0>
	// watermarking places the art in the background so build in reverse
	<cfloop 
		from="#arrayLen(variables.baseTemplateArray)#"
		to="1"
		step="-1"
		index="variables.wmIter">

		<cfpdf
			opacity="10"
			action="addWatermark"
			copyFrom="#variables.baseTemplateArray[variables.wmIter].T#"
			rotation="0"
			foreground="false"
			source="variables.createdPDF"			
			showonprint="true"
			overwrite="true"
			position="#variables.baseTemplateArray[variables.wmIter].P#"
			name="variables.createdPDF"
			>

	</cfloop>
</cfif>

I’ve spent a lot of time looking around for a solution but there is not a lot out there on this and I am running out of time as, if a solution doesn’t exist, I need time to create a service to run this through the old ACF9 server - which I’d rather not do.

Thanks in advance for any pointers (even if it’s “no, it can’t be done”)

Jeff


OS : Windows Server 2016 64bit
Java Version : 11.0.19 (Eclipse Adoptium) 64bit
Tomcat Version : na - using CommandBox - WildFly / Undertow - 2.2.24.Final
Lucee Version : Lucee 5.4.3.2
IIS : v10:
BonCode : Yes

couldn’t quite follow what you are asking from the title?

Do you mean watermarks are working, but coming thru in very low res, aka pixelated like the screens?

Yes, sorry I wasn’t clearer. :roll_eyes:

no problem, we figured it out

Yep, it’s a know issue, needs some java work on the pdf extension, switching from icePDF to PDFBox

https://luceeserver.atlassian.net/browse/LDEV-3047

2 Likes

Awesome, thanks @Zackster.

I’ve only got days before having to deploy a solution to Qa so I’ll go ahead and write a hook into the old CF9 engine for now and keep an eye on the LDEV-3047 issue.

Thanks again. Saves me a lot of stress knowing the path forward. :+1:

1 Like

for anyone wanting to get involved as a contributor to Lucee who knows a bit of java, this is a great first ticket

2 Likes

Related Ticket in JIRA: [LDEV-3934] - Lucee

1 Like