These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How to lock entire form after excuting "Save as..." command?

zxuan
Registered: Feb 1 2008
Posts: 14
Answered

I have created a PDF form with Acrobat Professional 8.0, there are over 20 textfield inside it. I hope that all fields will be locked after our vendors fill out the form. What should I do with Javascript? my computer is Mac OSX 10.4.11.

Need I add extra bottom inside the form? or can be fullfilled by code?

My Product Information:
Acrobat Pro 8.1.2, Macintosh
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You can add a script to the document "WillSave" event. In the script set all the fields to ReadOnly.

Use something like this.

this.getField("Myfield").readonly = true;

However, by itself, this is a very bad idea. At the very least you should have a validation script that checks the fields before locking them.

A better method would be to add a digital signature field to the form, then lock the fields when the user signs the form. This is a more formal process.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

zxuan
Registered: Feb 1 2008
Posts: 14
Thank you, thomp. I think the first choice is better to me. I have tryed to add a digital signature field to the form and it's ok. But I don't like meke it too complex.

Im from China, you know, I don't have any book about Acrobat Javascript here, I have to query many many material includes this forum to get the information what I need. I found that genuine JavaScript code can not be excuted in Acrobat, right?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You'll find the Acrobat JavaScript Reference and other materials on this web page.

http://www.adobe.com/devnet/acrobat/javascript.php

Core JavaScript, i.e., the language and basic object set, are the same everywhere. But each application that impliments JavaScript has a unique set of objects called the "DOM" that connect JavaScript to the application. Each application has a different DOM.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

landrew
Registered: Feb 15 2008
Posts: 12
I use the AFSignatureLock to simulate a signature field style lock using a checkbox. When the box is checked, the script will set goLock to 1 (true). I have a calculated field on the form that will perform the lock when the value of goLock is true, but there are several ways to test whether to lock or not.

The trick here is to name the form fields using a prefix. In my case I have fields called "SC.abc", "SC.def", "FF.SC.qwe", etc. When the lock is called all fields that begin with the prefixes in the array are locked.

Here is a snippet of code from one of my scripts:

var h = this.getField("InputField");
if(goLock == 1)
{
this.getField("FF.SC").display = display.hidden;
h.display = display.noPrint;
h.textColor = color.black;
h.readonly = true;
AFSignatureLock(this, "THESE", ["SC","FF.SC"], true);
}

Of course you also reverse your lock by placing "false" in the AFSignatureLock.

Enjoy!
zxuan
Registered: Feb 1 2008
Posts: 14
Thank you so much. Very kind of you!
webpointz
Registered: May 21 2009
Posts: 36
Hello,

Can anyone assist with this problem which is similar to this post?

1. PDF which has 3 editable acrofields and 1 digital signature field
2. Upon signing, the digital signature field has javascript that calls a function located in the CONFIG.JS file on the users PC
3. Script successfully saves the signed PDF to a network share folder.

Problem:

When signing, if the user selects checkbox to "lock document after signing", nothing happens, no save etc. If left unchecked it works fine.

Question:

How can I programmatically LOCK the document or get around the above issue. Is it because the document gets locked BEFORE the javascript function gets called?

Help!!