Locking Adobe Acrobat Forms

I created a form in Word and converted it to a PDF in Adobe Acrobat X.  I have a couple of form fields and a spot for a signature.  I would like the ability to lock this form so it can't be changed.

I have a java script that flatten the fields so it can't be edited.  This java script doesn't work when the form contains a signature.

Is there a better way to lock an Adobe document?

Java Script:
flattenFields()

 
function flattenFields() {

    if (app.viewerType=="Reader") {

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

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

            if (f==null) continue;

            f.readonly = true;

        }

    } else {

        this.flattenPages();

    }

}
Jonathan SuberIT DirectorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ivano ViolaSystem AdministratorCommented:
Do you have Adobe LiveCycle Designer? This usually come as a part with Adobe Acrobat X Pro. You can open the form in LiveCycle then set a password to edit the form.

IV
0
Jonathan SuberIT DirectorAuthor Commented:
The form needs to be filled out by a client and signed.  Once it is signed, I would like a button or menu item that locks the fields so no one can change data that was entered. Thanks, Jon
0
Ivano ViolaSystem AdministratorCommented:
Sorry about that. I read the question differently. What about something like a "Lock all fields" button?

http://forums.adobe.com/message/3168183#3168183

There is a form on this page that you can test. It may mean you'll need to change your form to be able to use the button. Do you have LiveCycle? This will make things easy. If not then if you can upload your form I can see if I can implement the button for you.

IV
0
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Jonathan SuberIT DirectorAuthor Commented:
That lock form button works great on that form.  I would like to use Acrobat if at all possible.  Live Cycle forms are larger than Acrobat and I will be uploading hundreds of these forms  into my SQL database.  

I do have LC but I have only used it a few times.  I have attached a sample patient consent and was wondering if you could place that button in my form?  Would I be able to cut and past it to other forms?  Thanks, Jon
Document1.pdf
0
Ivano ViolaSystem AdministratorCommented:
Does this work for you?

IV
Document1-Revised.pdf
0
Jonathan SuberIT DirectorAuthor Commented:
Yes it works great.  Now I need to get that lock button on about 15 different forms.  Is it simple just to copy and paste the script/button?  Thank you for all your help!  JDS
0
Ivano ViolaSystem AdministratorCommented:
jsuber-tchd,

I looked at it and I can't think of a way to get that functionality into your existing forms without using LiveCycle.

For it to work you need the button (that calls the javascript) and the javascript itself.

The Click javascript on the button calls the LockFields javascript.
LockFields.LockAllFields(Form1);

(Form1) is the name of the form.

LockFields javascript:

/*************************************************************************************
Function: LockAllFields
Description: This function will lock all fields.
IN: The parent subform. It could also be an element that contains subform like form1
OUT : nothing
**************************************************************************************/
function LockAllFields(myParentObject){

	var allChildElements;
	var intNumElements;
	var currentElement;
	var j;
	var temp;
	
	//Get all the child nodes of the parent element
	allChildElements = myParentObject.nodes;

	//Total number of element in the object
	intNumElements = allChildElements.length;
	
	//Loop through all the child elements
	for(j=0; j< intNumElements;j++){
		currentElement = allChildElements.item(j);
		//If the element is another subform we'll recusively call the function again
		if(allChildElements.item(j).className == "subform"){
			LockAllFields(currentElement);
		}
		//If the objects are fields and they are set to mandatory (validate.nullTest) then we will set the border.fill.color - dependant on object type
		else if(currentElement.className == "field"){
			//CHeck to see if the field is a button - do not lock buttons
			temp =  currentElement.name;
			if (temp.substring(0,6) != "Button"){ 
				currentElement.access = "readOnly";
			}	
			
		}
			//Check for exclusion groups - Radio Buttons
			else if(currentElement.className == "exclGroup"){
			for(k=0; k< currentElement.nodes.length;k++){
				if(currentElement.nodes.item(k).className == "field"){
					//set the color for the radio buttons individually
					currentElement.access = "readOnly";
				}
			
			}
		}	
	}
}//end function

Open in new window


This is what it looks like in LiveCycle:
LiveCycle Capture
IV
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jonathan SuberIT DirectorAuthor Commented:
This script works perfect.  Looks like I am going to have to learn Adobe LiveCycle to finish up my forms...Thank you for all your help.  Regards, Jon
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Acrobat

From novice to tech pro — start learning today.