Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
Version: Windchill 13.0
Use Case: Automatically adding a watermark to published PDFs of CAD drawings.
Description:
Looks like Creo View Adapters 11.0 and above have added a watermark option for NX PDF outputs!!
Automatically adding a watermark to published PDFs of CAD drawings.
I verified that this works on 11.0 Adapters and I'm guessing it's using the NX watermarking feature directly. These are all great things because in publish rules I can just add a watermark for the condition I want and it's done!
<additional-files
name="UG_drawing_pdf">
<file display-label="PDF" output-prefix="pdf" type="PDF" default="true">
<option name="Colors" value="BlackOnWhite" />
<option name="OutputTextOption" value="AsText" />
<option name="ConvertRasterImages" value="Yes" />
<option name="AddWatermark" value="DO NOT PRODUCE. FOR QUOTING ONLY." />
</file>
</additional-files>
However: It seems to only add uncapitalized text...
Thanks for sharing. Is that a hyperlink with "Automatically..." cause its broken. How do you mean uncapitalized text? Seems strange.
Curious about the hyperlink... How about this? Creo View MCAD Adapters 11.1 Installation and Configuration Guide .
In my publish rules, the watermark test is all capitalized.
<additional-files
name="UG_drawing_pdf">
<file display-label="PDF" output-prefix="pdf" type="PDF" default="true">
<option name="Colors" value="BlackOnWhite" />
<option name="OutputTextOption" value="AsText" />
<option name="ConvertRasterImages" value="Yes" />
<option name="AddWatermark" value="DO NOT PRODUCE. THIS DRAWING IS NOT RELEASED." />
</file>
</additional-files>
On the drawing, it shows up like this:
Curious if there's some sort of case conversion happening either on the Windchill end or NX... NX will display as written. Here, regardless of case the watermark displayed is lower case.
Looks like a bug to me. Did you log a case with PTC TS?
That said, I’m still a fan of pdfbox and writing one’s own code to watermark pdf files.
If you write your own code you have a lot of flexibility and you can watermark anytime, not just when publishing.
You can also set the text as a variable based on an attribute like state or whatever.
That's on my list of things to do, yes. I saw another post where you mentioned pdfbox. I started playing around with it and I think that will likely be a long term solution... especially when it comes to aliasing WTPart attributes onto CAD or having them drive particular text.
My thought was to try to go the way of the AfterEDRLoader to do this, but that works with the .pvs file.
Do you intercept the PDF creation somewhere to do the overlay or do it after the fact and then add back in to the representation?
While I have written the code to do an overlay I do not go that route when simply adding text.
I do not intercept the pdf creation. That creation is done by the native cad application (or MS word, excel). Intercepting it would be more complicated than this needs to be to get the job done.
I simply get the pdf and add the watermark.
I actually just did this for publishing WTDoc with pdfbox 3.0.5 (latest release version). Works great!
I’ve also written code with pdfbox to merge pdf files and add page numbers. As well as adding an image, which could be the watermark.
You can also control the exact location of the watermark. I like centered on the page diagonal but can be whatever.
My code also automatically sizes the watermark to be X% of the page’s diagonal. I like 50% but can be whatever.
You also can use any color and opacity too.
A few companies using this code. It’s bombproof.
It’s really very flexible. The sky’s the limit.