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

Digital Signature Automation

srobins
Registered: Feb 10 2011
Posts: 4

Hello all,
 
I'm looking to see how I can programmaticaly give a digital signature field code to run once it is executed.
 
I can do this in the GUI under, Properties of the Digital Signature Field, then the Signed Tab, then the "This script executed when signed", and place the javascript in there.
 
Is there a way with javascript to do this GUI option in code?
 

My Product Information:
Acrobat Pro 10.0, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
When, exactly, do you want such code to execute? I don't understand you first sentence, you want what code to run when what is executed? Are you looking for a way to sign a field programmatically?
srobins
Registered: Feb 10 2011
Posts: 4
Thanks for the reply, I'll try to be more clear.

I am looking for a way with javascript, to populate another field once a digital signature as been signed. I have the code needed to populate the field.

What I don't have is code to tell the digital signature field to execute this. This is possible in the GUI under the properties of the digital signature field, but I'm looking strictly javascript.

I have tried setactions, but I would like it to be code that is ran when the signature field is signed.

Thanks again.
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
I see. When you place code there, it is implemented as a custom Format script. So when you use setAction, specify the Format trigger.
srobins
Registered: Feb 10 2011
Posts: 4
This sounds good. I apologize, I am very new to javascript. Is there an reference for the javascript in Acrobat? I'm only finding 7.0 Javascript documents.

There is my code:

Saved as .js in Acrobat/javascripts

app.addToolButton({cName:"SL", cExec:"SignatureLine();", cTooltext:"Signature Line"});



function SignatureLine() {
var aRect = this.getPageBox( {nPage: 0} );
aRect[0] = 72;
aRect[1] = 108;
aRect[2] = 312;
aRect[3] = 72;
var d = this.addField("sig1", "signature", 0, aRect )

var bRect = this.getPageBox( {nPage: 0} );
bRect[0] = 360;
bRect[1] = 108;
bRect[2] = 576;
bRect[3] = 72;
var e = this.addField("date1", "text", 0, bRect )

//The code is what I want to populate into the date1 field after the signature field is signed.
//e.value = util.printd
//("dd mmm yyyy HH:MM z", new Date());
//this.getField("date1").readonly = true;

}
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
The most recent JavaScript reference can be accessed here: JavaScript for AcrobatClick the icon in the upper left of the web page to get the documentation to appear properly with a frame on the left showing the bookmarks.

Regarding your code, the getPageBox calls are returning information that you don't use. Did you want to add the fields to a location that's relative to the page boundaries?

To add the script, add a line after your var d = this.addField... line that's something like:

d.setAction({cTrigger: "Format", cScript: sJS});

where sJS is a string that contains the code you want to use. For example:

var sJS = "getField(\"date1\").value = util.printd(\"dd mmm yyyy HH:MM z\", new Date());\r";
sJS += "getField(\"date1\").readonly = true;";

I think I got that right...



srobins
Registered: Feb 10 2011
Posts: 4
Very nice.

Sadly, business needs are changing.. bleh! Thank you very much for this. This expanded my javascript by probably 2 times =)