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

trying to add current date and time to my PDF and it is not working... need help

New Here ,
Sep 30, 2019 Sep 30, 2019

Copy link to clipboard

Copied

I am trying to do the following.


var f = this.getField("Today");
f.value = util.printd("mmm/d/yyyy", new Date());


It works in acrobat but when I save as PDF it becomes static and no longer works.

I've been trying for 1 week everyday for hours and can not get it to work.

 

What can I be doing wrong?

 

 

 

Thanks

Views

3.4K

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 ,
Sep 30, 2019 Sep 30, 2019

Copy link to clipboard

Copied

Where does you place the code?

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 ,
Sep 30, 2019 Sep 30, 2019

Copy link to clipboard

Copied

In the action under page setting

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 ,
Sep 30, 2019 Sep 30, 2019

Copy link to clipboard

Copied

At all pages?

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 ,
Sep 30, 2019 Sep 30, 2019

Copy link to clipboard

Copied

Yes only have one page

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 ,
Sep 30, 2019 Sep 30, 2019

Copy link to clipboard

Copied

willing to pay you to fix

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
LEGEND ,
Sep 30, 2019 Sep 30, 2019

Copy link to clipboard

Copied

What is the app or browser in which it "becomes static"? 

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 ,
Sep 30, 2019 Sep 30, 2019

Copy link to clipboard

Copied

adobe reader

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 ,
Sep 30, 2019 Sep 30, 2019

Copy link to clipboard

Copied

Can you share the file?

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 ,
Sep 30, 2019 Sep 30, 2019

Copy link to clipboard

Copied

okay I will upload when i get home from work

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
LEGEND ,
Sep 30, 2019 Sep 30, 2019

Copy link to clipboard

Copied

That article describes how someone with Acrobat Standard can add the script if they do not know how to add a document level script without the GUI in the Form Tool.

 

Example Acrobat JavaScripts provides an extensive document level script in form that will only run once when the form is opened in Acrobat or Reader. There is also a link to an example file.The script issues a warning that the field is about to be updated. I have tried it in both Acrobat DC and Reader DC and the script runs.

 

If one wants to see the update change the value of the field in less than 24 hours, one can change the date format to include the time showing the hours, minutes and seconds. Your script will only work when the page on which the script is located is opened. So if one opens the PDF on say page 2 and the field is on page one, the field will not be updated. Using the document level script will update the field regardless of the page on which the field is located.

 

How have you determined that the field becomes static?

 

I created a PDF with your script but did not make the field read only and cleared the field before saving. The script ran. 

 

Another thing to do would be to open the JavaScript console and see if there are any errors.

 

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 ,
Sep 30, 2019 Sep 30, 2019

Copy link to clipboard

Copied

I got it to work! I re did the whole thing on another computer at home and it worked... now lets see if i take it back to my work computer if it will still be working then. Is there anyway I can remove the : from the time and the / from the date without setting off an error? Thanks for the help!

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 ,
Sep 30, 2019 Sep 30, 2019

Copy link to clipboard

Copied

You can remove : and /

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 ,
Oct 01, 2019 Oct 01, 2019

Copy link to clipboard

Copied

When I do hMMssmddyy without : / it has an error

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
LEGEND ,
Oct 01, 2019 Oct 01, 2019

Copy link to clipboard

Copied

It is within the quoted string in the "util.printd()" method.

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 ,
Oct 01, 2019 Oct 01, 2019

Copy link to clipboard

Copied

var f = this.getField("Today"); f.value = util.printd("hMMssmddyy", new Date()); and date format set to custom hMMssmddyy

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 ,
Oct 01, 2019 Oct 01, 2019

Copy link to clipboard

Copied

What error?

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 ,
Oct 01, 2019 Oct 01, 2019

Copy link to clipboard

Copied

adobe reader...... Invalid date/time: please ensure that the date/time exists. Field [ Today ] should match format hMMssmddyy" both are already matching

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 ,
Oct 01, 2019 Oct 01, 2019

Copy link to clipboard

Copied

one last question for you... how do i trigger a botton to run the textfield code?...

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
LEGEND ,
Oct 02, 2019 Oct 02, 2019

Copy link to clipboard

Copied

I would remove the any entry on the "Format" tab. The script is providing the format.

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 ,
Oct 02, 2019 Oct 02, 2019

Copy link to clipboard

Copied

Perfect

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 ,
Oct 02, 2019 Oct 02, 2019

Copy link to clipboard

Copied

Use something like this:

Sample

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 ,
Oct 02, 2019 Oct 02, 2019

Copy link to clipboard

Copied

Yes I got it to work copying yours but with my code it would not work correctly. The problem is when the doc is saved or sent in an email it will not save the time and date generated at that time of clicking the button. this code is working for what i needed but no button var f = this.getField("TimeStamp"); if (f.valueAsString=="") f.value = util.printd("mmddyyyyHHMM", new Date());.

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 ,
Oct 08, 2019 Oct 08, 2019

Copy link to clipboard

Copied

Yes this is exactly right except when saved it needs to stay on the page as it is. how can i do that?

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 ,
Oct 08, 2019 Oct 08, 2019

Copy link to clipboard

Copied

LATEST
Exactly correct! but when I save the page it needs to keep what was generated by clicking and not able to change again.

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