Is it possible to lock the dynamically created stamp using javascript
Copy link to clipboard
Copied
Hi,
is there any way to lock the stamp by default when it is placed using java script or any other mechanism . Now what we are trying to achieve is that need to lock the stamp.
Copy link to clipboard
Copied
Yes, there are a couple of ways to do this. Which one you use depends on what you are trying to achieve.
1) annotations have a "lock" property that when true keeps the user from being able to move the annotation. But otherwise the annotation keeps all of it's properties and the lock can be removed.
2) Annotations can be flattened, which makes the graphic on the annotation part of the page content, and all of the annotation features and properties are completely removed. All you get is the image on the annotation. And the original annot cannot be recovered.
Neither of these operations can be part of the stamp script. The script that either locks or flattens the annotation must be run from a different context.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
You can actually set the lock property to true if you put the code to do so in app.setTimeOut withing the stamp code. You just can't reference the stamp or it's "source". You need to get a handle to the stamp independent of any code that runs when the stamp runs. Generally, I just get the last stamp created and use a 250-millisecond timeout.
Copy link to clipboard
Copied
Good one. So probably the the AP and current page number is good enough for identifying the last stamp applied. Tricky though.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
... and a date sort. It's not foolproof but it works in common use cases.
Copy link to clipboard
Copied
Hi. I'm newbie scripting. Could you please make a example?
And, You mean that the blocked property is established in the stamp, in the moment you apply? or is permanent, which means any second user can´t delete never?
Thanks.
Copy link to clipboard
Copied
All annotations have a "lock" property. When set the annotation cannot be moved or resized. However, it is possible for a user to remove this property with a script from the console window.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
I mean to lock the stamp, not about the annotations. I would like to lock the stamp via scripting.
@Joel_geraci1 suggest using app.setTimeOut, but I'm newbie scrpting and I don't know how...
Copy link to clipboard
Copied
The stamp is a type of annotation.
The script joel is suggesting is not simple. I'd suggest you start by looking up the app.setTimeOut() function in the Acrobat JavaScript Reference. And the "doc.getAnnots()" function.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Are you sure this is a good idea? What if you want to move, resize or delete the stamp after applying it? Locking it will make it impossible to the regular user.
Copy link to clipboard
Copied
When I've set up the auto-lock for my customers, I also supply a menu item that can "unlock all annotations". In the use cases I've developed this for, that was acceptable.

