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
Details
This is (hopefully) our last hurdle porting ACF9 to Lucee…
The app uses data to build a PDF certificate based on
- the company issuing the certificate
- the authorised signatory of the qualification and
- 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…
<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