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
Copy link to clipboard
Copied
Where does you place the code?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
What is the app or browser in which it "becomes static"?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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.
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!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Use something like this:
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied