Skip to main content
Participant
April 17, 2019
Question

Is it possible to lock the dynamically created stamp using javascript

  • April 17, 2019
  • 2 replies
  • 1145 views

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.

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
April 17, 2019

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.

Joel Geraci
Community Expert
Community Expert
April 18, 2019

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.

Thom Parker
Community Expert
Community Expert
April 17, 2019

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.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Joel Geraci
Community Expert
Community Expert
April 17, 2019

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. 

Thom Parker
Community Expert
Community Expert
April 17, 2019

Good one. So probably the the AP and current page number is good enough for identifying the last stamp applied. Tricky though.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often