These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Stamp Name ...

Nico33
Registered: May 27 2010
Posts: 7
Answered

Hi,

I've just read the article about Dynamics Stamp Secret but i can't still do what i want.
Basically i would like to add via javascript a stamp on a document and then change some properties on it.
Here is what i do :

var annot = this.addAnnot({
page: 0,
type: "Stamp",
name: "vole",
rect: [400, 400, 550, 500],
AP: "NotApproved" });

then on a button :
var a = this.getAnnot(0, "vole");
a.opacity=50;

The problem is that i would like to do this with a custom stamp i've created and i can't find a way to get the name of the custom stamp ! so i cannot apply the "AP" when i create it ...

I'm trying to get the custom stamp name using event.source.stampName but an error happens when i run this line code :

event.value = event.source.stampName;
console.println("Stamp Name: " + event.source.stampName);

I'm pretty new to pdf and even with the document downloade on Dynamics Stamp Secret tutorial i can't get any name from my custom stamp....

If anyone can help ...

Regards

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
When you add the code to the stamp file you'll get an error because the "source" property does not exists at that time, i.e., when the stamp file is opened in Acrobat as a regular PDF. It only exists when the stamp is placed on a PDF.

But there is another way to get the stamp name. The name of stamp is also part of the template name, so you can get it from the "Page Templates" dialog. And it is also part of the language independant name of the menu item that activates the stamp tool. To get the menus read this article:

http://www.acrobatusers.com/tutorials/2008/06/executing_menu_items_from_javascript

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Nico33
Registered: May 27 2010
Posts: 7
Thank you for your answer but i found another way to get the stamp name :
var annots = this.getAnnots({ nPage:0 });for (var i = 0; i < annots.length; i++)if (annots[i].type == "Stamp") console.println("Stamp Name: " + annots[i].name);

here is what i wanted to do :
var vole = this.getAnnot(0, "b993d518-b832-4f0f-9e07-4783495fe6c3");vole.opacity=0; var resti = this.getAnnot(0, "624e0474-e914-4d7c-9117-79e0129af190");resti.opacity=0; var resti = this.getAnnot(0, "f3b3d2b2-9a36-4f58-aef0-2bb924954cc6");resti.opacity=0; var prime = this.getAnnot(0, "74cc97b7-79a2-4cea-bd90-1e445aefa2a3");prime.opacity=100;

Then switch the opacity value depending on what stomp to display, but saddly it works fine on my computer but badly on my mate's computer ...
I tried to do this placing images on button, hidding or not buttons as well but i also got some graphic bug.
I guess acrobat doesn't well support hidding/showing buttons or stamp ...

Anyway your link is very useful because this morning i was trying to execute the menu item (removeWatermark) and it didn't work, even adding the menu name in the whitreList. Need to learn a lot from acrobat obviously.

Thank you again.

Nico
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
All these issues you've mentioned do work. Its just a matter of getting the details down.

First, you can get the name of the stamp using a technique similar to what you've posted above. But the "annot.name" property is the name of the annotation instance on the PDF, not the stamp. The stamp name is in the "annot.AP" property.

Placeing images on buttons works fine. There are several field properties for controling how the image is displayed. Again you need to get the details down.

Hidding and showing also works perfectly.

Have you read my tutorials on placing annotations and fields on the PDF? Look through the JavaScript tutorials, there's lot of info there.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Nico33
Registered: May 27 2010
Posts: 7
No i havn't read your tutorial but i'll do it today cause i've got to manipulate field ...
Thank you again for your help.