Skip to main content
Alena_J
Participating Frequently
May 23, 2023
Answered

Script to lock all editable fields in PDF, then deletes the "Lock" button

  • May 23, 2023
  • 1 reply
  • 3308 views

Pretty much as the title mentions.

 

I need a button that once clicked, it runs a script which locks all the editable fields and deletes the lock button.

I know it can't be unlocked again, I need to lock it so it can be send it to a client afterwards, so I cant have the client modifying anything inside the PDF :D.

I once used this script many times, but I totally forgot how was the script, could anybody help, please?
I don't need anything more than this, no saving/sending. 
Thank you all very much 🙂

This topic has been closed for replies.
Correct answer Nesa Nurani

This will set all fields except 'buttons' to read only and then hide button where script is used:

for(var i = 0; i < this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if(f.type != "button")
f.readonly = true;}
event.target.display = display.hidden;

1 reply

Nesa Nurani
Community Expert
Community Expert
May 23, 2023

I don't think you can delete a field where you use script.

You can run a script to set fields to read only from console without need for button or delete button manually.

 

Alena_J
Alena_JAuthor
Participating Frequently
May 23, 2023

I know, I need the button for my colleagues to modify, lock and send to the client. If not delete I need to hide the button, so the client wont see there was a button in the first place. It's contract-like document. Digital only.

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
May 23, 2023

This will set all fields except 'buttons' to read only and then hide button where script is used:

for(var i = 0; i < this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if(f.type != "button")
f.readonly = true;}
event.target.display = display.hidden;