How to Populate PDF Form Fields from a Digital Signature Certificate
Question details
The user wants to automatically copy a signer's name and certificate information into other PDF form fields when a digital signature is applied, and clear the fields when the signature is removed.

- Product
- Device & OS
- not provided
- Scenario
- Creating a dynamic PDF form that auto-fills designated text fields based on the properties of a digital signature applied to the document.
- Observed behavior
- Destination fields need to dynamically update to display the signer's information upon signing and revert to a blank state if the signature is cleared.
Ensure you are using a PDF editor that supports JavaScript for forms, such as Adobe Acrobat, and that your document already contains a valid digital signature field and a destination text field.
Use Custom JavaScript Calculations to Extract Signature Info
Apply a custom calculation script to the destination field to read the signatureInfo object, and force the form to recalculate upon signing.
To automatically populate text fields with data from a digital signature, you can utilize the signature field's signatureInfo object via JavaScript. This method reads the certificate's embedded name and updates the text field accordingly. It also includes logic to clear the text field if the signature is removed.
Right-click your destination text field and select 'Properties'. Go to the 'Calculate' tab, choose 'Custom calculation script', and enter the following code: var sig = this.getField("Signature1"); if (sig.valueAsString == "") event.value = ""; else event.value = sig.signatureInfo().name;
Right-click the Digital Signature field (e.g., "Signature1") and select 'Properties'. Go to the 'Signed' tab and add the following script to execute when the document is signed: this.calculateNow();
Apply a digital signature using your certificate to verify that the destination text field populates with the signer's name. Right-click the signature to clear it and confirm that the destination text field goes blank.

Manage PDF Forms and Signatures Seamlessly with WPS PDF
While advanced JavaScript can automate form extraction, WPS PDF offers a highly intuitive interface to quickly create, manage, and securely sign PDF forms without complicated coding.
- 1. Open your PDF in WPS Office: Download and launch WPS Office, then open your PDF document using the WPS PDF tool.
- 2. Manage Form Fields: Navigate to the 'Form' tab to easily add, edit, or customize text fields, checkboxes, and signature fields.
- 3. Apply a Digital Signature: Go to the 'Protect' tab and click on 'Sign Document' to securely apply your digital certificate to the required signature fields.

Frequently Asked Questions
Why doesn't the target text field update immediately after I sign the document?
The PDF viewer needs to be instructed to recalculate the form fields after the signature is applied. Adding 'this.calculateNow();' as a signed script on the signature field ensures all calculation scripts run instantly upon signing.
Can I rely on the visual appearance of a digital signature on a PDF form?
No, you should never rely solely on the visual appearance of a signature, as images can be faked easily. Always check the actual properties of the signature and verify the certificate in the PDF viewer's signature panel.
Why does my text field show an error or retain text when the signature is cleared?
This happens if your script lacks a condition for empty values. Ensure your custom calculation script includes an IF statement (e.g., if (sig.valueAsString == "") event.value = "";) to clear the field when the signature is removed.
What happens if a self-signed certificate is used to sign the document?
The script will still extract the name from the self-signed certificate. However, because anyone can generate a self-signed certificate with any name, it does not securely prove the user's identity to third parties.




