Copy link to clipboard
Copied
Hi,
Good day everybody, I have 500 documents that needs to be digitally signed and I want to automate this process. I wanted to know can I automate this process using javascript? If not, how can I automate it using action wizard without having to select the digital id and entering th password of the id manullay for each file?
Seeking for solutions 🙏🙏
Thank you
Yes, you can do it using a combination of an Action and a script.
Read the documentation of the signatureSign method of the Field object to learn how to do it.
Copy link to clipboard
Copied
Yes, you can do it using a combination of an Action and a script.
Read the documentation of the signatureSign method of the Field object to learn how to do it.
Copy link to clipboard
Copied
Ok thanks, I will give it a try, please help me if get stuck somewhere
Copy link to clipboard
Copied
// Get the signature field object
var signatureField = this.getField("signatureField");
// Get the security handler for digital signatures
var ppklite = security.getHandler("Adobe.PPKLite");
// Configure the digital signature parameters
var signatureParams = {
password: "alvarocuba5456",
location: "San Francisco, CA",
reason: "I approve this document",
contactInfo: "id@gmail.com",
appearance: "Handwritten"
};
// Login to the security handler
ppklite.login({cPassword: "alvarocuba5456"});
// Set the digital ID to use for the signature
var digitalID = {
oPKCS7: util.readFileIntoStream("/D/temp/myid.pfx"), // Path to PFX file
password: "alvarocuba5456"
};
// Add the digital signature to the signature field
signatureField.signatureSign(ppklite, signatureParams, digitalID);
// Logout of the security handler
ppklite.logout();
NotAllowedError: Security settings prevent access to this property or method.
Field.signatureSign:26:Console undefined:Exec
undefined
I tried this code but it is not working, if you don't mind can you please show a code snippet on how to do it properly?
Copy link to clipboard
Copied
Never mind, I just did it 😅, thanks for the help
Copy link to clipboard
Copied
will you be able to share the code? I am trying to do the same for my company to save time
Copy link to clipboard
Copied
Hi @okboo_7867,
Hope you are doing well. Thanks for writing in!
The error encountered in the above script —NotAllowedError: Security settings prevent access to this property or method
—indicates that certain security restrictions are preventing your code from executing as intended.
Unfortunately, JavaScript in Acrobat has strict security limitations, especially concerning digital signatures. The signatureSign
method used above is often restricted in standard JavaScript contexts.
Here's an alternative approach you can take to set up digital signatures programmatically, while also considering the limitations:
Use the Trusted Functionality: Ensure your JavaScript is running in a trusted context. You may need to set Acrobat preferences to allow JavaScript to access certain functionalities.
Use Pre-Signed Certificates: If you can pre-sign documents and store them with your certificate, you can automate the process of applying signatures without needing to input the password each time.
If you still want to attempt automation within the allowed limits, here’s a simplified snippet you could try, though it may not resolve your issue if security restrictions apply:
// Ensure that the script is running in a trusted context
if (app.trustedFunction) {
var signatureField = this.getField("signatureField");
// Configuration for digital signature
var signatureParams = {
location: "Add-your-location",
reason: "add-your-reason",
contactInfo: "abc@abc.com",
appearance: "Handwritten"
};
try {
// Attempt to sign the document
signatureField.signatureSign({
cPassword: "your-password-here", // Password for the digital ID
oPKCS7: util.readFileIntoStream("/location/certificate.pfx"), // Path to PFX file
password: "your-password-here" // Password for the PFX file
}, signatureParams);
} catch (e) {
console.println("Error signing the document: " + e.message);
}
} else {
console.println("The script is not running in a trusted context.");
}
Hope this helps.
-Souvik