Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Lock image fields with signature

New Here ,
Nov 26, 2021 Nov 26, 2021

Hi All,

Im currently trying to set up a PDF form where the users can insert screenshots and then sign the form. It works very well with the prepare form -> add an image field tool. If I understand correctly, this creates just a form field with the JavaScript command event.target.buttonImportIcon(). Unfortunately, I cannot find a way to lock the images trough signature. Does anybody know if there is a solution to this? Signature action -> lock all fields does not work, I still can replace the images after. If it does not work by signature, maybe there is a way that the javascript can only be run once to prevent changing the image later.
Many thanks in advance for any thoughts on this

TOPICS
Acrobat SDK and JavaScript , Windows
508
Translate
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 Expert ,
Nov 26, 2021 Nov 26, 2021

It's probably because the image of a button field is not really a value, technically speaking.

However, under the Signed event of the signature field you can set the fields as read-only, which will prevent the user from editing them.

 

The code to do so is the following:

 

for (var i=0; i<this.numFields; i++) {
	var fname = this.getNthFieldName(i);
	var f = this.getField(fname);
	if (f==null) continue;
	f.readonly = true;
}

 

Translate
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
New Here ,
Nov 27, 2021 Nov 27, 2021

Hi,

thank you very much for your quick reply. Unfortunately, this locks all fields, but the image fields still work. I now added an if statement to check that the signature field has not been signed before executing the java command to update the field icon. This works pretty good so far:

 

if (getField("Signature1").value == "")
{event.target.buttonImportIcon();}


Best regards,

Tobias

Translate
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 Expert ,
Nov 27, 2021 Nov 27, 2021

That's not possible. If the field is set as read-only clicking it will do nothing.

But your solution works too!

Translate
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
New Here ,
Dec 04, 2021 Dec 04, 2021

So far it works very well. 

But maybe there is another thing that would be really helpful. Is there a way to adapt your code to only lock fields that contain a certain string? For example "fname" contains "_part1".

 

I use forms with multiple parts where a signature only locks this specific part. Picking the fields manually is not very efficient.

Translate
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 Expert ,
Dec 04, 2021 Dec 04, 2021
LATEST

Sure.

Before this line:

f.readonly = true;

Add this:

if (/_part1/.test(fname))

Translate
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