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

todays date in acrobat

New Here ,
Jul 10, 2016 Jul 10, 2016

I would like to create a form that when printed the date it is printed appears on the top of the form. I have found the following;

In brief:
1. Add form field with the read only property and hidden but printable general options.
2. Add a JavaScript tot the Will Print document action.

this.getField("PrintDateFieldName").value = "Printed on: " +util.printd("mmm d, yyyy", new Date()) + " at " + util.printd("h:MM tt", new Date());

You need to change the field name to your field name and the format of the date and time to the style you want.

Working with date and time in Acrobat JavaScript - Part 2 by Thom Parker

The problem I have having with these instructions are the following; when I go to Add the JavaScript a box appears to add javascript and when you put in the javascript the two options you have is "cancel" or "Go to" and you have to choose a line in the ?document? or ?editor? . All the instructions I can find regarding this all say to add the javascript and hit close or OK but neither is an option when adding new javascript. Any advice?

Look at similar directions below. I know I am a novice...please be gentle with me  

10down voteaccepted

Remove your script and replace it with the following document javascript:

var f = this.getField("wells_datefield");

if (!f.value) f.value = util.printd ("m/d/yyyy", new Date());

Save your form and open it, and the date should pop right in there.

When making the document javascript, remember to not put it inside a function. One way of doing that is the following. In the Acrobat menu:

  1. Advanced->Document Processing->Document Javascripts...
  2. In the dialog that pops up, enter a Script Name (for instance "populate_date") and click Add...
  3. In the script dialog that pops up: REMOVE everything ("function populate_date(){}") and paste in the script above.
  4. Click ok, then Close.
  5. Save the form, close it and reopen it.
  6. There is no step 6! 😆

TOPICS
Acrobat SDK and JavaScript , Windows
1.2K
Translate
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 ,
Jul 10, 2016 Jul 10, 2016

What version of Acrobat do you have?

Translate
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 ,
Jul 10, 2016 Jul 10, 2016

Acrobat DC Version 2015.016.20045

I am a subscriber to creative cloud.

Translate
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
LEGEND ,
Jul 10, 2016 Jul 10, 2016

Can you post a screen shot of the dialog that you think should have the OK button?

Translate
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 ,
Jul 10, 2016 Jul 10, 2016

Screenshot for putting in javascript.PNG

Translate
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 ,
Jul 10, 2016 Jul 10, 2016

You need to make the window bigger and then you'll see the OK button, to the left of the Cancel button.

Translate
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 ,
Jul 10, 2016 Jul 10, 2016

OMG!!!! That is just too funny!!!!

I've been spending hours....and just plucked out the last hair on my

head....Thank you!!!

Translate
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 ,
Jul 10, 2016 Jul 10, 2016

Further follow up question.

I got this functioning. But...what I would like to accomplish is that this form is available for various people to access, When they go to print it out then the date and time automatically update and print out with the date/time that the form is printed. Currently this has a stagnant date time that is reflective of when I created the form.

Translate
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 ,
Jul 10, 2016 Jul 10, 2016
LATEST

No, it should update each time the file is opened.

If you want it to update before each time the file is printed instead then you should click the Document Actions button instead of Document JavaScripts and then set that code under the Document Will Print event.

Translate
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