Skip to main content
Participant
September 5, 2018
Beantwortet

Print out date on PDF files using javascript - not updating

  • September 5, 2018
  • 1 Antwort
  • 4160 Ansichten

Hi,

We're using Adobe Acrobat Standard 2017 and need to get the print out date on some PDF's. In earlier versions it was easy to add the script and the date was updated when file opened. Now we can not get this to work.

This is what we've done:

  • Create the PDF
  • Click Prepare Form
  • Add a text field called "Today"
  • Changed properties for text field
  • Calculate - Custom calculation script
    This is the script we used: var f = this.getField("Today");f.value = util.printd("yyyy/mm/dd", new Date ());

The date and time appear but it is not updated, it remain the same date and time as when the properties for the text field were applied.

Anyone have any idea why and how this can be solved? Not needed to use JavaScript, putting date in footer is also a solution but we've tried also this With same result, date is static, not dynamic.

Dieses Thema wurde für Antworten geschlossen.
Beste Antwort von try67

You need to place the code as a doc-level script, so that it will execute each time the file is opened. A calculation script is only executed when the value of any field in the file is changed, not when the file is opened. Unfortunately for you, the Standard version of Acrobat doesn't give you (direct) access to doc-level scripts, but you can get around it by executing this code from the JS Console:

this.addScript("load", "this.getField(\"Today\").value = util.printd(\"yyyy/mm/dd\", new Date());");

1 Antwort

try67
Community Expert
try67Community ExpertAntwort
Community Expert
September 5, 2018

You need to place the code as a doc-level script, so that it will execute each time the file is opened. A calculation script is only executed when the value of any field in the file is changed, not when the file is opened. Unfortunately for you, the Standard version of Acrobat doesn't give you (direct) access to doc-level scripts, but you can get around it by executing this code from the JS Console:

this.addScript("load", "this.getField(\"Today\").value = util.printd(\"yyyy/mm/dd\", new Date());");

Participant
September 5, 2018

Thanks try67 for your answer.

Just one question: how do I access the JS console in my version (Adobe Acrobat Standard 2017). Ctrl+J do not bring up ythe console and I can not find it in any menu.

try67
Community Expert
Community Expert
September 5, 2018

Ctrl+J should work...