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

Lock fields and hide fields with digital signature

New Here ,
May 08, 2023 May 08, 2023

I am using Acrobat Pro 2020. I have a document that needs to set as read-only (lock? it needs to make the fields un-editable) all of it's fields except a second signature field once the first signature field is signed. I was using the built-in functionality to "Mark as read-only: All fields except these" and then listing the second signature field. This method was working fine but now I must add a drop down field ("DD1") that once an item is selected, it auto-populates two other drop-down fields ("DD2" and "DD3"). What I would like to happen is when the first signature field is signed, all of the fields except the second signature block become read-only, and the first drop-down field ("DD1") becomes hidden. The PDF is never actaully printed, it's only used digitally, so that's why using the field property "Form Field: Visible/Hidden/Visible but doesn't print/Hidden but printable" won't suffice.

From my understanding, I have to use a script that marks the fields as read-only and sets "DD1" to hidden because I can only select one option for what happens when the first signature field is signed. Any help with figuring a script like that out would be really helpful!!

TOPICS
How to , JavaScript , PDF , PDF forms
1.5K
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
1 ACCEPTED SOLUTION
Community Expert ,
May 08, 2023 May 08, 2023

Yes, you will need to use a script to do it, and while it can't actually lock the fields, it can set them as read-only.

You can use the following code for that:

 

this.getField("DD1").display = display.hidden;
for (var i=0; i<this.numFields; i++) {
	var fname = this.getNthFieldName(i);
	var f = this.getField(fname);
	if (f==null) continue;
	if (f.name=="Signature2") continue; // Do not "lock" the other signature field
	f.readonly = true;
}

View solution in original post

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 ,
May 08, 2023 May 08, 2023

Yes, you will need to use a script to do it, and while it can't actually lock the fields, it can set them as read-only.

You can use the following code for that:

 

this.getField("DD1").display = display.hidden;
for (var i=0; i<this.numFields; i++) {
	var fname = this.getNthFieldName(i);
	var f = this.getField(fname);
	if (f==null) continue;
	if (f.name=="Signature2") continue; // Do not "lock" the other signature field
	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 ,
May 08, 2023 May 08, 2023

This worked PERFECTLY. Thank you so much. I spent so much time trying to jerry-rig a script to try and do what I wanted.

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 ,
Jan 04, 2024 Jan 04, 2024

Can you tell me where I put the code? I've never done it before and think is a solution i need for my file.  TIA

 

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 ,
Jan 05, 2024 Jan 05, 2024
LATEST

Under the Signed event of the first signature field:

 

try67_0-1704448296236.pngexpand image

 

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