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

How to instantiate a Lock Object for setLock() for signature fields?

frleong
Registered: Apr 23 2007
Posts: 6

Hi, it's me again. Thanks a lot for your answer. Actually, I've tried to use setLock() before and I succeeded in calling it via trusted folder level script. However, I don't know how to instantiate a Lock object. How should I declare a lock object in Javascript, if I don't get it through getLock()? I tried to create a normal Javascript object and set the corresponding properties, but setLock() rejected this object.
 
-- Quoted Answer
It returns null because there are no lock properties associated with the field. The "setLock()" function needs to be called first. Unfortunately "setLock()" is a privileged funtion, you're not going to be able to call it directly from the VB script.
 
One way to get around this problem is to place all code for creating and setting up the signature field into a trusted function in a folder level script. Then call the trusted function from the VB app.

My Product Information:
Acrobat Pro 7.0.9, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The "setLock()" entry in the Acrobat JavaScript Reference has a spec for the Lock Object. This is a generic object, which means that it can be defined as a JavaScript Object Literal, like this

var myLock = {action:"Include",fields:["myfld1","myfld2"]};

You can see an example of the lock object by setting up the lock properties manually and then calling "getLock()" from the JavaScript Console.

this.getField("mySig").getLock().toSource();

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

klops12345
Registered: Oct 10 2011
Posts: 3
I am trying to prepare a PDF form with a signature field which will lock all the other fields when signed. I was struggling with a similar problem that frlong had but after creating a function in a folder level something started working. So what I have for now is a button which signs the signature field and locks all other fields. The problem is I am passing the password and ID path within the function which simply makes passwords useless. What I would like to obtain is a no-button system with a signature field only, which will lock all other fileds after signing, save to chosen direction and e-mail to a predefined address.

function LockAfterSigning(sMyActions, sMyFields, sMySignature)
{
var MyLock = {action:sMyActions,fields:[sMyFields]};
var f = this.getField(sMySignature);
var oLock = f.getLock();
oLock = MyLock;
f.setLock(oLock);


var ppklite = security.getHandler("Adobe.PPKLite");
var oParams = {
cPassword: "1234qwer",
cDIPath: "/C/ID/John.pfx" // Digital signature profile
};
ppklite.login(oParams);
f.signatureSign(ppklite,
{
password: "1234qwer",
}
); //End of signature



ppklite.logout()

}

Thanks for any support.



Piotr Andrzejewski
Adobe Acrobat X Pro