Add watermark/stamp to document

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
zbarna
User
Posts: 21
Joined: Thu Dec 08, 2011 9:01 am
Location: Budapest

Add watermark/stamp to document

Post by zbarna »

Hi!

Is it possible to add a watermark(for example a text), to the document when displaying it in the viewer sdk control?

Thanks for the information in advance!

-------------------EDITED

I found the stamps in pdfxchange viewer, and maybe it's enough for us, but I can't add stamp to the document :( .
I read the documentation, but found only how to set the properties of the stamp, but it won't add stamp to the document automatically.
I tried this:
PDFXCview.SetProperty("Commenting.Stamp.Styles[0].Type", "Expired");
PDFXCview.SetProperty("Commenting.Stamp.Styles[0].Opacity", 0.5);

I think I have to call PDFXCview.DoVerb with the right parameters, to add the stamp to the document.

Could you help me in this, how to add the stamp to the document?

--------------------------

Best Regards,
Zoli
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17941
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Add watermark/stamp to document

Post by Tracker Supp-Stefan »

Hello Zoli,

You can add a stamp using JS code in our Viewer.
The below sample is taken from the JavaScript for Acrobat API Reference :

Code: Select all

var annot = this.addAnnot({
page: 0,
type: "Stamp",
author: "A. C. Robat",
name: "myStamp",
rect: [400, 400, 550, 500],
contents: "Try it again, this time with order and method!",
AP: "NotApproved" });
And in the sample projects included with the SDK you should be able to see how to execute JC code in our Viewer.

Best,
Stefan
zbarna
User
Posts: 21
Joined: Thu Dec 08, 2011 9:01 am
Location: Budapest

Re: Add watermark/stamp to document

Post by zbarna »

Hi!

Thank you very much for your reply. Good to know that, I can run javascript with your viewer :) .

Unfortunately it's not fully what I want, but almost :) .

The problem is that I can select the stamp, after I inserted it to the document. For example the user can move with grabbing, and when he zoom into the document, he can't scroll with his mouse by grabbing the document, because he selects automatically the stamp instead of the document.

So is it possible to make the stamp not selectable somehow?

Or Could you write me, how can I put a watermark to our document like "demo version" :), with custom text. Maybe this would be the best solution for us, instead of stamps.

I saw this in the js api reference, what you linked: (addWatermarkFromText), but I can't use it :( .

Thanks for your help in advance!

Best Regards,
Zoli
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17941
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Add watermark/stamp to document

Post by Tracker Supp-Stefan »

Hi Zoli,

Please check the readOnly property for annotations - and set it to True for the ones you create - this way they would display but would not interact with the user in any way.

Best,
Stefan
zbarna
User
Posts: 21
Joined: Thu Dec 08, 2011 9:01 am
Location: Budapest

Re: Add watermark/stamp to document

Post by zbarna »

Hi!

Thanks for the reply!

I tried it, but it's only make the annotation to unmodifiable, so the user is not able to remove or resize it, but he can select it, so it isn't good :( .

I checked all of the properties of the annotation, but I found nothing which makes the annotation unselectable for the user. :(

Do you have any other idea? Or what about to use watermarks, it's impossible?

Thanks for your help in advance!

BR,
Zoli
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17941
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Add watermark/stamp to document

Post by Tracker Supp-Stefan »

Hi Zoli,

You can flatten the annotation after placing it - but this will flatten all annotations on a given page, so it might not be an elegant solution.

I am now checking with my colleagues for other possible options.

Best,
Stefan
zbarna
User
Posts: 21
Joined: Thu Dec 08, 2011 9:01 am
Location: Budapest

Re: Add watermark/stamp to document

Post by zbarna »

Hi Stefan,

Thanks! I will try to flatten it, but yes it is not so elegant :) .

I'm waiting for the other possibility, thanks for checking it :) .

BR,
Zoli
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17941
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Add watermark/stamp to document

Post by Tracker Supp-Stefan »

Hi Zoli,

And please make sure you are creating copies of your files before adding/flattening annotations to them! As flattening is not a reversible process.

Best,
Stefan
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom
Contact:

Re: Add watermark/stamp to document

Post by John - Tracker Supp »

Hi,

sorry to say - it is not possible to make the annotation 'Visible' but unavailable in the manner required - so the only solution is the one suggested by Stefan.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
zbarna
User
Posts: 21
Joined: Thu Dec 08, 2011 9:01 am
Location: Budapest

Re: Add watermark/stamp to document

Post by zbarna »

Thanks for your replies!

I think the problem is solved! :)

I just call the "this.flattenPages()" at the end of the javascript, and it will flatten my annotations, so the user can't select it.

I don't have to backup my pdf files, because the pdf viewer sdk won't modify it. I added the stamp annotation, than flattened it, and after that I opened the pdf file again, and it was the same like before I added annotations.

So I think it works :) .

Thanks for the help again!

Best Regards,
Zoli
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17941
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Add watermark/stamp to document

Post by Tracker Supp-Stefan »

Hi Zoli,

Glad to hear that this works for you! But please make sure that you do not allow the user to manually attempt to save a file - or the stamps will be saved. (You can close the file without saving it, but if you are not intercepting the save command - a user could potentially hit Ctrl-S and save the file with the flattened annotation).

Best,
Stefan
zbarna
User
Posts: 21
Joined: Thu Dec 08, 2011 9:01 am
Location: Budapest

Re: Add watermark/stamp to document

Post by zbarna »

Thanks for reminding me! :)

I use this to disable the save function. With this the user can't save the pdfs right?
PDFXCview.SetProperty("Commands[\"Save\"].State", "Offline", 0);

BR,
Zoli
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17941
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Add watermark/stamp to document

Post by Tracker Supp-Stefan »

Hi Zoli,

You are welcome, and yes - this is the proper command.

Best,
Stefan
Post Reply