Copy link to clipboard
Copied
I have been making some PDF for my clients for them to edit information and after that, they send it to third part but, of course, need to "lock" the PDF after using a reader version. Is it possible?
Sure. You can use this code:
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f==null) continue;
f.readonly = true;
}
Copy link to clipboard
Copied
You can make the fields read only using JavaScript.
With Digital Certificates you can not only lock field but also add special code to detect any changes since the signing of the form.
Copy link to clipboard
Copied
Can i use java script in adobe reader?
I made a form to send it to my client, after he fill it, he will send to the third part. What we would like is to lock the form only for the third part
Copy link to clipboard
Copied
Depends on what commands you're using. You can set the fields as read-only in Reader using JS, yes.
Copy link to clipboard
Copied
Can you explain to me how to do it with JS?
Copy link to clipboard
Copied
Sure. You can use this code:
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f==null) continue;
f.readonly = true;
}
Copy link to clipboard
Copied
I will sound like a stupid, but i dont really know where to put this code in adobe reader
Copy link to clipboard
Copied
This code will work in Reader, but to apply it to your file you must have Acrobat.
Copy link to clipboard
Copied
I have acrobat. But my client and the third part dont have it, only the reader.
Copy link to clipboard
Copied
That's fine. You can create a "Lock Form" button and attach this code as it's MouseUp action.
Copy link to clipboard
Copied
Where is teh option of create a button?
Copy link to clipboard
Copied
What version of Acrobat do you use?
Copy link to clipboard
Copied
My version is acrobat pro DC, and my client's version is only reader.
Copy link to clipboard
Copied
Go to Tools - Prepare Form, and then use the Button tool to draw your field.
Right-click it and select Properties. Go to the Actions tab. Add new MouseUp triggered event and add an "Execute JavaScript" command, and then paste this code into the window that opens.
Set the rest of the button's appearance properties and you're done!
Copy link to clipboard
Copied
Is it possible doing it with reader version?
Copy link to clipboard
Copied
No! I answered this question multiple times already... You have to set it up in Acrobat and then the code will work in Reader.
Copy link to clipboard
Copied
I dont need to "lock" the form in acrobat, I need to lock it in reader. I create the form, send it to my client and he will fill it and after that he will need to lock the form and send to the third part. So, my client doesnt have acrobat version.
Copy link to clipboard
Copied
When you create the form with Adobe Acrobat you can also add the code.
Copy link to clipboard
Copied
I don't know how to explain it differently... If you follow my instructions it will work.
Copy link to clipboard
Copied
I know this is from 2017. I do this with Acrobat Pro but there is no "Execute JavaScript" command in the list when I go tthe actions tab for the button. If not, how can I add the command?
Copy link to clipboard
Copied
What does you see at the action list?
Copy link to clipboard
Copied
This does work well with a button however, lets say I wanted this code to execute upon being saved in Reader; how would one do that? I tried applying this and similar variations of code under Document Actions "Document Will Save" and it technically works...however I can't even save the form to distribute because it makes everything read only when I save it haha. Any help with this conundrum would be greatly appreciated. Thank you!
Copy link to clipboard
Copied
Well, it's working as advertised... What you can do is disable JS before saving the file, via Edit - Preferences - JavaScript.
Copy link to clipboard
Copied
@try67 This was brilliant! (Once I figured out how to fix the settings after accidentally clicking the yellow Javascript warning and telling it to "Always trust Javascript" for this particular document. Thank you so much for the simple yet brilliant advice!
Copy link to clipboard
Copied
Hello, I have a question:
Is it possible to add in your code some kind of exception? I want to lock most of the document except a few form fields: e.g. I created a button that will lock all the form fields fiiled in by the applicant, but will leave unlocked some form fields for the administration. Is that possible? I'm not a developer, so I can't code...
I wonder if you would add in the code somewhere, a command in the lines of "lock all form fields readonly= true, but leave "FieldNameXYZ"=false.?
Is this possible?
Thanks in advance and kindest regards,
Nuno