Skip to main content
Participant
April 2, 2019
Question

Why is this so complicated, insert today's date

  • April 2, 2019
  • 2 replies
  • 7045 views

Had no idea something so simple would end up being so complicated.  I have a pdf file I created in the latest version of Acrobat Pro DC, it has a signature field and a text box next to that for the date. I will be gathering the signature using Adobe Sign.  All I want is for the text box to populate with today's date when the form is opened.  All the help I've been able to find says I need to add javascript to the Page Open event but I can't seem to find that in Acrobat DC. Even the Adobe help page for this seems to describe an older version of Acrobat so it's not helping me much. I'm just frustrated with how complicated this is ending up, why doesn't Adobe have a simple function to add today's date on a form?

This topic has been closed for replies.

2 replies

JR Boulay
Community Expert
Community Expert
September 19, 2020

All this is useless, a signature is necessarily dated, otherwise it is worthless.

Acrobate du PDF, InDesigner et Photoshopographe
Participating Frequently
September 19, 2020

this is obvious
but my form is a copy of a paper document where the "date" field is and therefore I have to put it on the electronic form

rayek.elfin
Legend
April 3, 2019

It's not that hard: just put the following script in your document level javascript:

var dateToday = util.printd("mmmm dd, yyyy", new Date());

this.getField("currentDate").value = dateToday;

Make sure your date field is set to read-only, and named "currentDate".

The problem with Acrobat Pro is that its user interface has changed dramatically over the past 5 years, and many tutorials, while the javascript still works, are no longer valid in regards to where things can be found.

In Acrobat DC, you have the Tools view, where you will find the JavaScript tool. You then can add it to the Right Hand Panel. The JavaScript tool has the javascript options.

Thom Parker
Community Expert
Community Expert
April 3, 2019

You'll need to verify this strategy by following it through the entire Sign process.  Forms sent for Sign are handled differently than regular forms.

And there is another issue. This document script will always set the date, every time the document is opened. Is this what you want to happen? Or do you want the date only to be set when the user fills the form?

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
September 19, 2020

You made me a little sad with that answer.
But I noticed that for a single signature the script works (after modification) even after extracting the page
in my case there will be a different signature on each page but the date field may be the same (Date)
The question is whether it is possible to create a script that first checks if the given fields exist (Signature1, Signature2, .. etc.) and then returns the date value for existing fields


Try this:

 

var dateToday = util.printd("mmmm dd, yyyy", new Date());
var signedStatus1 = event.target.getField("Signature1")==null || event.target.getField("Signature1").signatureInfo().status==0;
var signedStatus2 = event.target.getField("Signature2")==null || event.target.getField("Signature2").signatureInfo().status==0;
var signedStatus3 = event.target.getField("Signature3")==null || event.target.getField("Signature3").signatureInfo().status==0;
if (signedStatus1 && signedStatus2 && signedStatus3) {
    this.getField("Date1").value = dateToday;
    this.getField("Date2").value = dateToday;
    this.getField("Date3").value = dateToday;
}