Hello. I've managed to create a dynamic stamp that is behaving strangely and was wondering if someone might have some insight as to the cause. I've created a simple stamp that consists of two buttons and two text fields. In one of the fields there is a custom calculate script that sets the value of the text to which it is attached, and for debugging purposes, shows this value with an app.alert. I've set it up so it (should) only execute when the stamp is being applied. For example:
if (event.source.forReal && event.source.stampName == "myStampName") {
...code goes here
}
The alert happens when the stamp is applied, which I would expect. The weirdness is the script is also triggered whenever the stamp is rotated, even if I save the stamped document, close Acrobat, reopen the document that I stamped, and rotate the stamp. It is not triggered when the stamp is moved or resized.
Something even weirder is whenever the stamp is rotated, Acrobat adds a document-level icon to the document, with a name like: stampname-ENU-13
where "stampname" is the name of the stamp and the number at the end so far has been 0, 1, 13, 22, 34, and 45. I tried modifying other dynamic stamps with the same code and they do not behave the same way. It's a Frankenstamp.
The same stamp behaves the same way both on my Windows 7 machine (9.3.4) and Mac 10.6.6 (9.4.0). I haven't tried anything else yet.
I'm going to be troubleshooting this more tomorrow and will provide a sample file if I don't find anything and anyone is interested, but I thought I'd first see if anyone has experienced anything similar.
And no, I'm not drunk, just a little tired.
Thanks for reading!
This strangeness goes far beyond the odd bug stage. The fact that Acrobat is both calling the original code and creating document level icons implies a deliberate intent. All form fields, code, etc. are destroyed when the stamp is placed. Have you examined the stamp annot dictionary to see if anything is saved there? If nothing is saved in the stamp then the only connection back to the original stamp code is the stamp name. Have you tried removing the stamp file altogether to see if it still reacts to a rotate? What is the stamp name? Something has to be triggering the actions. The most likely candidate is the name.
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script