Is it possible to lock the dynamically created stamp using javascript

Community Beginner ,
Apr 17, 2019 Apr 17, 2019

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.

TOPICS
Acrobat SDK and JavaScript

Views

244

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 17, 2019 Apr 17, 2019

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.

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 17, 2019 Apr 17, 2019

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. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 17, 2019 Apr 17, 2019

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.

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 18, 2019 Apr 18, 2019

Copy link to clipboard

Copied

... and a date sort. It's not foolproof but it works in common use cases.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 13, 2020 Apr 13, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 13, 2020 Apr 13, 2020

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. 

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 14, 2020 Apr 14, 2020

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...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 14, 2020 Apr 14, 2020

Copy link to clipboard

Copied

LATEST

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.

 

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 17, 2019 Apr 17, 2019

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 18, 2019 Apr 18, 2019

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines