• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Can Acrobat auto populate a Name field upon digital signature of a form?

Community Beginner ,
Dec 17, 2019 Dec 17, 2019

Copy link to clipboard

Copied

I know you can auto populate a Date Field upon Digital Signature from a form but I'd also like to auto populate a Name Field. I am making a form which requires a Digital Signature for approval, along with the client's Name and Date of Approval. I have added the required Java script to generate the Date but I was wondering is there a way to generate the Name based on the name information from the digital signature?

TOPICS
PDF forms , Security digital signatures and esignatures

Views

6.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 3 Correct answers

Community Expert , Dec 28, 2019 Dec 28, 2019

You can use this code to do it (as the Signed script of your signature field):

 

var f = event.target;
if (f.signatureValidate()==4) {
	var Info = f.signatureInfo();
	this.getField("SigName").value = "Signed by: " + Info.name;
	this.getField("SigDate").value = "Signed on: " + Info.date;
} else {
	this.getField("SigName").value = "";
	this.getField("SigDate").value = "";
}

Votes

Translate

Translate
Community Expert , Nov 07, 2020 Nov 07, 2020

Please disregard my last post as it doesn't answer your question and I am still working on this script.

 

To extract the date as it appears in the digital certificate you need to use a combination of util.scand() method with util.printd() method, and new Date().

 

The date and 24 hour clock time (that such certificate also use with a Gregorian calendar format (as I am reading))  is expressed in Zulu time , which observes Daylight Savings time; also referred to as UTC for Universal Coordinated Ti

...

Votes

Translate

Translate
Community Expert , Feb 14, 2023 Feb 14, 2023

Great!

 

And thank you for sharing this.

 

To clear the contents of the date field when the signature field is cleared, you may use a custom validation script or custom calculation script executed directly from the date field.

 

Something like this:

 

 

if(this.getField("mySignatureField").value == "") event.value = "";

 

 

OR,

 

You may also add a Mouse Exit event to the signature field:

 

 

if(event.target.value =="") this.getField("Text34").value = "";

}

 

 

With the latter script, when th

...

Votes

Translate

Translate
Community Expert ,
Dec 18, 2019 Dec 18, 2019

Copy link to clipboard

Copied

Hi,

 

I've been trying to work on similar with  a PDF form of my own.

 

I've recently came accross this possible solution but I haven't tested it on my end:

 

https://experienceleaguecommunities.adobe.com/t5/Adobe-LiveCycle-Questions/Create-digital-initials-a... 

 

 

This is an old thread for the date , there is a very short script that works for me for the date part:

 

https://community.adobe.com/t5/acrobat/can-acrobat-auto-populate-a-date-field-upon-digital-signature... 

 

 

Si when you say digital signature I assume you're referring to electronic signature in the context of digital certificates by which certificate validation and encryption are involved.

 

You may also need to dig deeper on how to use signatureInfo part in your script to get first, middle, last names appropriately from  such digital certificate signatures.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 18, 2019 Dec 18, 2019

Copy link to clipboard

Copied

Just to clarify, I already have this script in the: Digital Signature Properties > Signed > This script executes when field is signed >

// JavaScript code to add the date at signing time var currentTime = new Date() var month = currentTime.getMonth() + 1 var day = currentTime.getDate() var year = currentTime.getFullYear() var signingTime = day +"/"+month+"/"+year //Modify into your preferred format var f = this.getField("Date1_af_date"); //Modify the field name as necessary f.value = signingTime;

Which propagates the correct date in the Date Approved filed of my form when the Signature is actioned. There's also a Approved By field where the user enters their Name. I was hoping the name supplied in the digital signature could be used here but I have no idea what script to use. And, even if there was a script would it clash with what's already there for the date action?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 18, 2019 Dec 18, 2019

Copy link to clipboard

Copied

in the first link  that I posted earlier above you can use that one to grab the name.

 

Here is how I would do it:

 

  • To avoid the two scripts clashing you don't need to use the same ApprovedBy field; use two fields instead but make it seemless to the user by marking them as readonly.

 

 

So again, a quick easy solution is to create two read-only text form fields (one that will grab the date from the signature field and the other one to grab the name ).

 

All you have to do is add a custom calculation script in both of those text form fields like:

 

for the date try this:

var grabdate = this.getField("yoursignaturefieldname").valueAsString;

 

if (grabdate=="") event.value ="";

 

or use this other method if you choose to use a datefield where the date will be pulled from the signature field with this other method: https://stackoverflow.com/questions/35232909/how-do-i-trigger-javascript-events-when-a-signature-is-... 

 

And for the field that will pull the name portion of the signature field use  the same script  above that I just typed as a reference in the custom calculation script section of that text field:

 

(getField("mySig").value !== '') // signature is present    getField("myDate").value = global.getCurDate(); // custom function for a mm/dd/yyyy date
else    getField("myDate").value = '';

 but change the global ogject  from global.getCurDate to the appropriate

 

global.get object of the API reference

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 18, 2019 Dec 18, 2019

Copy link to clipboard

Copied

Excellent! I shall give it a try and see how it goes!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2019 Dec 28, 2019

Copy link to clipboard

Copied

Hi,

 

just checking and curious if you were able to make this work in your PDF document

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2019 Dec 28, 2019

Copy link to clipboard

Copied

I don't see why this is necessary. The signature field itself already contains the name of the person who signed it, as well as the date it was signed...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2019 Dec 28, 2019

Copy link to clipboard

Copied

I know but I personally have a similar issue with the packet that I shared with you.

 

I am working with another packet that can exceed over 30 forms that need digital signatures.

 

Next to the signature field the signer have to type in their full name and select a date. Those are governement forms, so it is a requirement for yhe user to inout their name and date and then digitally sign with a certificate.

 

The signing authorities are not necessarily savvy on how to apply signature workflow, so as a workaround this would allow the signer just to sign the field and not  to worry about typing their  names and manually selecting dates.

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2019 Dec 28, 2019

Copy link to clipboard

Copied

You can use this code to do it (as the Signed script of your signature field):

 

var f = event.target;
if (f.signatureValidate()==4) {
	var Info = f.signatureInfo();
	this.getField("SigName").value = "Signed by: " + Info.name;
	this.getField("SigDate").value = "Signed on: " + Info.date;
} else {
	this.getField("SigName").value = "";
	this.getField("SigDate").value = "";
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2019 Dec 28, 2019

Copy link to clipboard

Copied

Thank you so much!!

 

I've spent literally 8 to 12 months trying to figure this out.

 

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2019 Dec 28, 2019

Copy link to clipboard

Copied

You're very welcome!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 02, 2020 Jan 02, 2020

Copy link to clipboard

Copied

This is an excellent piece of code! I was wondering if I can restrict the amount of information in the Name field to just the name (and remove the Signed By: and Email address - see attached screen shot). Thank you either way!

 

screen-shot.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 03, 2020 Jan 03, 2020

Copy link to clipboard

Copied

Sure. Use this:

this.getField("SigName").value = Info.name.split(" <")[0];

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 05, 2020 Jan 05, 2020

Copy link to clipboard

Copied

Excellent. Thanks for all your help everyone!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 02, 2020 May 02, 2020

Copy link to clipboard

Copied

++Update

 

Hi,

 

Long time since this thread was posted.

 

I just wanted to share this piece of  code that also worked for me. The code below  gets just the distinguished name label from the digital certificate used in the digital signature and populates it in another text field:

 

 

var f = this.getField("SigName");
var sigInfo = f.signatureInfo();
var cert = sigInfo.certificates[0];
this.getField("Text1").value =  cert.subjectDN.cn;

 

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 05, 2020 Nov 05, 2020

Copy link to clipboard

Copied

This works but how do I extract and the date that was already shown on the digital signature block? thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 05, 2020 Nov 05, 2020

Copy link to clipboard

Copied

I improved this script a little better.

 

This script populates the name to a desired textfield printed as first name , middle initial (if there is one, and last name).

 

I came accross this soultion due to people using certificate based digital signatures with a smart card. But it should work too with self-signed certificates as long as the same digital signature conventions are followed for the distinguished name.

 

The scripts also populates the current date at signing time.

 

I am using it as a Mouse-up action script:

 

var f = event.target;
    var sigInfo = f.signatureInfo();
    var date = util.printd("yyyymmdd", new Date());
    var sigInfo = f.signatureInfo();
    var cert = sigInfo.certificates[0];

    var firstName = cert.subjectDN.cn.split(".")[1];
    var lastName = cert.subjectDN.cn.split(".")[0];
    var middleName = cert.subjectDN.cn.split(".")[2];
    var dodNum = cert.subjectDN.cn.split("'.")[3];
    var c = middleName.charAt(0);
    var d = c.toUpperCase()+".";

    var first = firstName.charAt(0).toUpperCase() + firstName.substring(1).toLowerCase();
    var last = lastName.charAt(0).toUpperCase() + lastName.substring(1).toLowerCase();



if (f.valueAsString !=="") {
  
this.getField("myDateField").value = date;


if ((c == "1")|| (c == "2")||(c == "3")||(c == "4")||(c == "5")||(c == "6")||(c == "7")||(c == "8")||(c == "9")||(c == "0")) { this.getField("myPrintedNameField").value = first+" "+ last;}

else if ((c !== "1")||(c !== "2")||(c !== "3")||(c !== "4")||(c !== "5")||(c !== "6")||(c !== "7")||(c !== "8")||(c !== "9")||(c !== "0")) { this.getField("myPrintedNameField").value =  first+" "+ d+" "+last;}

}

 

Let us know if this works for you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 07, 2020 Nov 07, 2020

Copy link to clipboard

Copied

Please disregard my last post as it doesn't answer your question and I am still working on this script.

 

To extract the date as it appears in the digital certificate you need to use a combination of util.scand() method with util.printd() method, and new Date().

 

The date and 24 hour clock time (that such certificate also use with a Gregorian calendar format (as I am reading))  is expressed in Zulu time , which observes Daylight Savings time; also referred to as UTC for Universal Coordinated Time.

 

UTC is basically a timezone (Greenwich Mean Time, in London I believe) that helps separates (or identify) the East and West geographical regions based on Sunrise and Sunset, for example, to include moonrise and moonset.

 

This is important to know because when  you're performing  a forensic analysis of a signature date and time stamps, You'll notice that the signature timestamp won't match that of the textfield where it is copied to (like the minutes and seconds,  and the Zulu timezones).

 

This is due to the script that was used which only takes the current time from the computer's  system clock at signing time, not from the digital certificate that was used with the certificate-based digital signature.

 

I am taking the time to explain all of this because I've noticed that most developers in the Acrobat forums use the "new Date()" method to get the current date at signing time, but this is not correct and it is not the same as extracting the exact Zulu date and time that is embedded in the digital signature (which is also filtered by the signature field's securtiy handler mechanism).  

 

I work a lot with government forms. And from a security and validation standpoint, when I examine a digitally signed PDF, if  the date that was extracted onto another textfield doesn't have the same number of minutes and seconds, it basically invalidates the whole document during an audit.

 

In occasions, I have to kick it back the PDF for corrections because it looks fishy (specially on inspectable paper trail,  and more specifically even if the creator of the form didn't do this intentionally).

 

But in my experience, it just so happens that a lot of people in an office space are always trying to mess around with the wrong hacks in an attempt to make their lives easier at work. I hope that you're not one of those.

 

And to be honest I am starting to regret the fact of sharing so much info here in the forums for free. What I am about to share with you should be a paid-for solution.

 

Anyway,  to avoid this problem for good, you NEED to use this method: 

 

 

 

var f = event.target;

var sigInfo = f.signatureInfo();


//THIS WILL GET THE EMAIL

var Email = this.getField("sigInfo4").value = sigInfo.name.split(">")[1]+sigInfo.name.split("<")[1].split(">")[0];


//THIS WILL GET THE COMMON NAME OF THE SUBJECT

var SubjectName = this.getField("sigInfo3").value = sigInfo.name.split("<")[0];


//THIS WILL GET THE DATE AND TIME FROM THE SIGNATURE AND POPULATE IN ANOTHER FIELD IN ZULU TIME 

this.getField("myDateField").value = util.printd("ddd mmm dd yyyy HH:MM:ss ZZ", new Date((util.scand("ddd mmm dd yyyy HH:MM:ss ZZ", sigInfo.date )) ) );

/* NOTE: TO CHANGE THE DATE TO ANOTHER DATE FORMAT JUST CHANGE THE PART INSIDE THE QUOTES OF  util.printd("ddd-mm-yyyy",  FOR EXAMPLE BUT LEAVE EVERYTHING ELSE UNCHANGED IN THAT LINE OF CODE. ALSO, DO NOT DECLARE A VARIABLE WITH THE LINE OF CODEABOVE FOR util.printd(), IT WILL THROW AN ERROR WITH THE new Date() FUNCTION*/  




//GET THE VALIDATION STAUS OF THE SIGNATURE FIELD, IT CHANGES WHEN IT IS UNSIGNED AND CHANGE AGAIN WHEN THE SIGNATURE IS APPLIED

if (f.signatureValidate()==4) {


//PERFORM THE EXTRACTIONS FOR THE COMMON NAME AND EMAIL

 this.getField("myNameField").value = SubjectName;

 this.getField("myEmailField").value = Email; 


}

 

 

 

Note also that the line of code that I used for the extraction of the date is outside of the "signatureValidate()" function condition.

 

You have to run it outside of this validation or you will not get the date when a user signs with a smart card. 

 

Using the code like this allows to extract the date from both a self-signed certificate or a smart card-based certificate(s). 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 13, 2023 Feb 13, 2023

Copy link to clipboard

Copied

Extracting from ls_rbls - this is what worked perfectly for me.
When signed, the document fills out a date stamp next to it automatically.


Insert Text Box next to Signature > Right-click the Text Box > Properties > mark Read Only and close.


Script: Right-click the Signature > Properties > Signed > Edit > Paste the following:

var f = event.target;

var sigInfo = f.signatureInfo();

this.getField("Text34").value = util.printd("yyyymmdd", new Date((util.scand("ddd mmm dd yyyy HH:MM:ss ZZ", sigInfo.date ))));

if (f.signatureValidate()==4);

 

... but ... Hahah.

 

If I remove the signature, how do I delete the data without changing the box to NOT be Read-Only.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2023 Feb 14, 2023

Copy link to clipboard

Copied

LATEST

Great!

 

And thank you for sharing this.

 

To clear the contents of the date field when the signature field is cleared, you may use a custom validation script or custom calculation script executed directly from the date field.

 

Something like this:

 

 

if(this.getField("mySignatureField").value == "") event.value = "";

 

 

OR,

 

You may also add a Mouse Exit event to the signature field:

 

 

if(event.target.value =="") this.getField("Text34").value = "";

}

 

 

With the latter script, when the signature field is cleared and the mouse pointer is moved outside of that field it will set the date field to a blank value.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines