Skip to main content
15-Moonstone
November 5, 2013
Question

Watermark rev of wt.part on the published drawing

  • November 5, 2013
  • 32 replies
  • 20183 views

I am hoping somebody already figured it out, and it is not a costly customization...

32 replies

1-Visitor
March 3, 2014

After 2-3 weeks, I finally got a call back from PTC & they found/knew the way to get the waternarking to show in PDF's

In watermarking, the PDF is considered a Document Page.

So when I assumed I only needed to create a Drawing page with attributes in it, I needed it for Document Page.

The ptc person had me "edit", "copy" the Drawing Page & "edit", "copy to all" from the watermark editor.

Then save that ini file & replace old with new, with same ini file & place back up at site/org, utilities, Visualization
Configuration Administration
, & replace the config ini that was initually up there. the same one the server_prefs.xml points to.

Then all was good.

Let me know if any questions, if this didnt make as much sense as when I typed it.

I attached the new one (afs_03.ini, where the other one I attached before, was afs_01.ini). They are different names now, because I added a couple extra attributes. But the new one cleary show (drawing & document, ecad, etc)

Larry Jett

1-Visitor
March 4, 2014

New Dilemma,

I guess I recently realized that the DRW's PDF's that are stored in the windchill vault, are likely published through Reader.

Where the watermarks (ootb windchill &/or creo view) arent applied till you open them into Creo View. You can save, print to pdf & email from there & those PDF's will have the watermark.

But that does no good for automating & placing into the windchill vault & associating to the windchill DRW.

So that means that my previous & current code (shown below), wont allow for download/save of a pdf with watermarking.


Code:

URL:

URL url = data.getViewContentURL(holder);

Download:

ContentServerHelper.service.writeContentStream(data, path);

Does anybody have a route to get pdf's automated either into the vault & associated to the DRW or downloaded to a shared drive, with watermarking.

A route thats not costly or heavy programming. I dont mind the programming, but with things like iText, isnt there a licensing fee?

Is it cheap?

Any ideas, methods?

Thanks
Larry Jett
datajett@aol.com

1-Visitor
March 4, 2014
You can still use iText as long as you do not sell or redistribute what you
are using it for.i.e some PDM utility, that's when it becomes a commercial
license arrangement.


1-Visitor
March 4, 2014

Great to hear. I will look into iText then. I will have to see if my current client is willing to spend the time & dime on me doing the coding.

Any idea of how long it should take for a normal developer (myself). Thats means double your time, at least...ha..ha

I just spoke with a ptc support person on watermarking & they also mentioned purchasing Adobe LiveCycle (if I spelled that right) & creating a doc worker. Which he said would create pdf's with watermark. Then also associate it to the DRW in windchill, which wouldplace that pdf into the vault through db meta-data.

Same as publishing with pro & thumbnail worker, I think.

But its a purchased item. Anybody know what the livecycle costs?

Thanks
Larry Jett

1-Visitor
March 16, 2014

Well, I started on the lengthy customized watermarking. I like the najanaja & iText route, but after watermarking the downloaded published pdf, I cant get it up to replace the default representation.

I want it there, so if anyone views, downloads, etc, they get the watermarked pdf.

I used updateContent route:

newAppData = wt.content.ContentServerHelper.service.updateContent( holder, newAppData, (java.io.InputStream) is);

But I could only get it to go up as an SECONDARY attachment. I even accidentally got it to go up as PRIMARY & replace the DRW, but I cant find the code to get it to go up as representation, derivedimage, etc & become the default representation.

What am I missing &/or can I even send the watermarked pdf as a rep?

Thanks
L Jett
datajett@aol.com

1-Visitor
March 16, 2014
Lawrence,

I can think of two potential solutions to handle this. They are as below:

*Potential Solution 1 (CadConverter extension point)*:

- Write a custom CadConverter
- Update method doDrawingConversion() to call your custom stamping utility
(iText?) and generate stamped PDF
- Compile and deploy your custom CadConverter
- Update wvs.properties to use custom CadConverter in place of OOTB
CadConverter. Search for entries such as:

publish.cadconvert.ACAD

publish.cadconvert.PROE


Draft custom CadConverter is attached to this email.

*Note:*

- I have used this solution to implement certain other behavior

- I have not used this solution to implement stamping/watermarking


*Potential Solution 2
(PublishServiceEvent.PUBLISH_COMPLETE/PUBLISH_SUCCESSFUL listener)*:

- Write a custom listener to listen for PUBLISH_COMPLETE event
- Retrieve the representation object
- Retrieve the ApplicationData for PDF file from representation object
- Download PDF file from the representation
- Call your custom stamping utility (iText?) and generate stamped PDF
- Retrieve streamdata from applicationdata

Streamed streamdata = (Streamed) applicationdata.getStreamData().getObject()

- Store new PDF file using

streamdata.storeStream()


*Note:*

- I have used PUBLISH_SUCCESSFUL event to trigger generation of custom
WTDocuments (to store PDF)

- However, I am not sure, if "storeStream()" can be used to replace
existing content. This has to be validated.


--
Rochan Hegde
Productspace Solutions Inc.

1-Visitor
March 16, 2014

Hello & Thanks Rochan,

I am basically using writeContentStream to download:

ContentServerHelper.service.writeContentStream(appdata, theFile.getAbsolutePath() );

I am currently working on my own watermarking through iText. Someone from NajaNaja sent me a link for their watermarking, but I need further iText customizing, because my client needs a date for release state change on pdf.

So I have most of what you spoke of covered.

I currently have code to add the watermarked pdf as an attachment:

newAppData = wt.content.ContentServerHelper.service.updateContent( contentcookie, newAppData, (java.io.InputStream) is);

But the area that you mention you have not verified yet,is why I posted this message.
I cant find the route to create a representation.

I can likely replace the existing default representation, with the new rep, becauseI found that code.

But I just cant find the code to create a representation.

updateContent looks great for adding content, but there doesnt seem to be something as nice or at all, for represenatations.

L Jett

1-Visitor
March 16, 2014
Lawrence,

I assume that, PDF files are generated by publishing EPMDoducmnet
(Drawing). You are then using customization to stamp/watermark PDF file.
Also,

- You have the code to store stamped/watermarked PDF as an attachment

- But, you want to store stamped/watermarked PDF as representation


When a publish job is created in Windchill, CadConvert
(CadConvertPROE, CadConvertACAD etc) calls method "doDrawingConversion" to
trigger generation of PDF output file. Once the PDF is generated, Windchill
calls method "storeDrawingRepresentation" to store files as representation.

So, you need to call your customization after "doDrawingConversion" is
called and before "storeDrawingRepresentation" is called. You just have to
replace CAD worker generated PDF file with stamped/watermarked PDF file.
Windchill automatically picks up the PDF and stores it as representation.
You need not have to call any method related to representation. Check the
pseudo code in my earlier email.

--
Rochan Hegde
Productspace Solutions Inc.


1-Visitor
March 17, 2014

Wow, I wasnt aware of storeDrawingRepresentation & doDrawingRepresentation.

I will certainly look into those 2 methods & how to intercept the doDrawingRepresentation.

I will look at the code you attached & reread your comments on which does what & when & go from there. I am sure you detailed it well, but If I miss the full path, I will ask for detail in the area I am missing.

But thats is some good research you have done & thats why we come to ptcuser.org.

I really appreciate the help.

Thanks
L Jett

1-Visitor
April 22, 2014

Thanks to Rochan, I finally, finally got watermarking working for default representation (or any rep). I took your CustomCadConvert.java & just adjusted it a little.


You suggested editing & working in the doDrawingConversion, but I the temp folder there only held the drw, etc.


I decided to let Creo View Publish a pdf, so I worked in the storeDrawingRepresentation method.
I found the folder where the published pdf resided & copied it to a temp name (in same temp folder).
Then read the original pdf through the iText reader. Stamp & write to the temp pdf.
Then copy the temp pdf to be the same as original name & over write the original pdf. All in pub temp folder.

iText would not read & write at the same time, to the same pdf, as far as I could find. So I had to make a copy.


I attached the code, but it has extra code to read the DRW related child info (creation date, state, rev) for stamp text.
The client didn't want the DRW info, incase they differ. They wanted the date of the epmdoc as the change notice & new rev were created.


But if some one wants the DRW info for stamp, they can just remove this method (& its while loop):


navRefQR = EPMStructureHelper.service.navigateReferencesToIteration(epmDRW, null, false, configSpec);


It also has code to read the info for the 1st iteration of the current Rev & if you don't want that method (& its while loop), remove:


QueryResult qr = VersionControlHelper.service.allIterationsOf(epmDoc.getMaster());


You might have to adjust the epmDoc/epmDRW names.


This code was a major pain, but I learned a lot & it didn't help that they threw me too many interfering tasks.


The code should be split into multiple separate methods &/or classes, but after getting it to work, I was tired of it..LOL


So please view & let me know of any errors/issues, but it works. But of course, you don't know about errors, till its in production mode & some user throws an unplanned taskat it & it fails.


Hope all enjoy.


Larry Jett
datajett@aol.com