These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Automatic Update Date field

marthe
Registered: Mar 16 2011
Posts: 5

I have created a new text field into a pdf form and I have set it up to do a calculation with the formula:
 
event.value = (new Date()).toString();
AFDate_FormatEx("m/dd/yyyy");
 
It gives me the date. But It keeps this date for the pdf file. The only way I can get it to update is to open the prioperties of the field in edit mode, choose the Calculate tab, and click edit and OK to update the field.
 
Is there a way for me to make this date automatically update when opening the pdf file?
 
I am not literate in Acrobat, so an outline on doing this would really help.
 
Thanks,
John

My Product Information:
Acrobat Pro 9.4.2, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Set the data in a Document Level Script. The document scripts are run when the PDF is opened. On the "Advanced" menu seletect the "Document Processing > Document Javascripts" item. Then on the dialog enter a name and press "Add". This pops up an edit window. Delete the automatically generated code and enter

this.getField("YourDateField").value = (new Date()).toString();

Set the formatting for the date with the field format property.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Updating any field that modifies a calculation is the action that triggers the calculation action at the field level.

If you want the date to change when the PDF is opened, you need to place the code at the script location that is processed upon the PDF file being opened. This is the Document level script action. You will have to modify your code due to the change of the location. Look at Thom Parkers tutorials about date calculations.

George Kaiser

marthe
Registered: Mar 16 2011
Posts: 5
Thanks Thomp, that works.

John