Skip to main content
Known Participant
September 12, 2019
Answered

*Solved* Need to make an entire pdf read only except for a handful of fields

  • September 12, 2019
  • 4 replies
  • 5667 views

I have a 2 page sales contract that needs to be made read only before being sent to a customer BUT there are a handful of fields that the customer might need to update, so these need to stay open.

 

I've seen various answers on here but can't find exactly what I need. I have a code in use on another document, but that makes the whole doc read only and you can't reverse it the action once the button has been pushed.

 

For info, I can't change the field names on my document as they are actually merge fields, but the fields I want to stay open I can add a prefix, so is there a code that will make all fields read only apart from the ones with a prefix of OPEN?

 

I've also seen on here that you can add a password to this action so if the salesperson hits the 'make read only' button early, he can reverse it by inputting a simple '1234' for example. He also has to input this to make the doc read only in the first place.

 

Thank you!

 

 

This topic has been closed for replies.
Correct answer brettt25731202

you're welcome. I'm glad it helped.

 

Were you able to work around the script successfully?


Yes, I grouped the fields and used the below with the digital signature.

This script executes when field is signed.

this.getField("Group1").readonly = true;
{
}
this.mailDoc({cTo:"john.smith@xxx", cSubject: "Request", cMsg: "Please send signed document "});

4 replies

ls_rbls
Community Expert
Community Expert
September 16, 2019

I assume that by prefixing you have determine how to group the fields that you want to hide and/or keep visible after the user selects YES or NO.


This means naming each group with a prefix following the example in this thread:

 

https://community.adobe.com/t5/Acrobat/editing-show-hide-field-list-via-javascript/td-p/3819705

 

 

Then adding a separate javascript action to your button or incorporating it in your current working script by adding these lines:
getField("OPEN").display = display.visible;
getField("HIDE2").display = display.hidden;

jlehaneAuthor
Known Participant
September 17, 2019
Perfect! Works like a dream - thank you very much 🙂
jlehaneAuthor
Known Participant
September 16, 2019

I've done some digging elsewhere and I've cobbled together the following - it doesn't look pretty but it works for what I want ...

 

var r = app.alert("Are you ready to make this document read only?",2,2);
if (r == 4) { // 4 is Yes, 3 is No
for (var i = 0; i < this.numFields; i++) {
var fname = this.getNthFieldName(i);
this.getField(fname).readonly = true; // makes all fields readonly
// Sett all of the OPEN fields to NOT read-only
getField("OPEN").readonly = false;
}
}

 

..BUT, I also need hide some other fields when the document is made read only. No problem adding these as separate actions, but the fields get hidden even if the user clicks 'no' to the above question (are you ready to make this documenet read only?). How can I make it so these other fields only get hidden if the user clicks 'yes'?  These other fields are all prefixed with HIDE

 

 

 

ls_rbls
Community Expert
Community Expert
September 15, 2019

jlehaneAuthor
Known Participant
September 16, 2019

Thanks, but this doesn't really do what I want.

The contract is open and the salesperson fills it in (with the customer via the phone). When he's finished, he needs to click a button that makes the specific fields read only (prices, term etc). Salesperson then sends it to the customer and they fill in the open fields (the direct debit mandate for example). I cannot add a signature field as we need a wet signature.

I'm after a JS to make the above happen on the click of the button. 🙂

ls_rbls
Community Expert
Community Expert
September 15, 2019

You may also consider adding a digital signature field for the customer.

 

In the properties for that field you can add actions through a java script OR you can assign an action to the aignature field to make read-only just the fields that you need to become read only or the entire document

brettt25731202
Inspiring
November 22, 2019

Is_rbls,

I am using the below code to turn everything to read only but the second signature.  When the first signature is complete .I have three check boxes that I need to leave unlocked.  If I am reading the code correctly??? the signature field is staying available based on the field type, if (f.type!= "signature").  If so, can I just use the same for check box? if (f.type!= "check box").  If Yes where should it go? I tried it and it didn't work, what should I use? 

 

Thanks for the help

 

for (var i = 0 ; i < this.numFields ; i++) {

var f = this.getField(this.getNthFieldName(i)) ;

if (f.type!= "signature") //

{

f.readonly = true ;

}

}


this.mailDoc({cTo:"", cSubject: "CAB QUAD Request", cMsg: "Please review and electronically Sign Document"});

ls_rbls
Community Expert
Community Expert
November 23, 2019

Hi,

 

Have you prefixed all your signature fields and your three checkboxes like shown in this link: https://community.adobe.com/t5/Acrobat/editing-show-hide-field-list-via-javascript/td-p/3819705 

 

Also , I noticed that in this line of your script : if (f.type!= "signature") //

The "//" are commenting the next line of code, you should remove the forward slashes.

 

And my other question, are the signature fields requiring digital certificate or just a regular signature field where the user will be using the Sign Tool to type in a name  or to just  draw an ink signature?