Automatic Date Field
You may want to know the date that a user completes a form. You
can insert a text field in your PDF form that will automatically insert
the current date. This field uses a simple JavaScript at the page level.
Adding an automatic date field is a two-step process: First you must add the Date field. Then, you must add the JavaScript to the
Page Properties.
- Inserting the Date Field
- Adding the JavaScript
Inserting the Date Field
The date will appear as part of a text field.
-
Open the PDF file that you will use the form for
-
From the Forms menu, select Add or Edit Fields...
Adobe Acrobat 9 Pro enters Form Editing mode and the Forms toolbar appears.
-
Click TEXT FIELD TOOL
HINT: The cursor changes to a cross hairs. The cross hairs allow you to align the field with the ruler, text, or another field.
-
Position the cursor where you want the text field to begin
-
Click and drag the mouse until the text field reaches the desired size
-
Release the mouse button
The Field Name entry box appears.
-
In the Field Name text box, type a name for the date field
EXAMPLE: Type Today
NOTE: The name that you assign will be used in the Javascript and must match.
-
Click SHOW ALL PROPERTIES
The Text Field Properties dialog box appears.
-
On the General tab,
in the Common Properties section, select Read Only
NOTES:
An option is selected when a check appears in the box next to it.
This is necessary for calculated fields such as a date.
- On the Format tab
- From the Select format category pull-down list, select Date
-
From the Date Options scroll box, select a date format option
NOTE: This representation of
the date format will be used when adding the JavaScript. An example of
the date format is shown below the list.
-
Click CLOSE
The date field is inserted.
Adding the JavaScript
The javascript is applied to the page. Therefore, you must be out of
Form Editing mode.
-
If you are not out of Form Editing mode, click CLOSE FORM EDITING
-
From the Navigation pane, click PAGES
NOTES:
The Pages pane opens.
This action toggles between hiding and displaying the Pages pane.
-
Right click the page thumbnail of your form that contains the Date field » select Page Properties...
The Page Properties dialog box appears.
-
Select the Actions tab
-
In the Add an Action section, from the Select Trigger pull-down list, select Page Open
-
From the Select Action pull-down list, select Run a JavaScript
-
Click ADD...
The JavaScript Editor dialog box appears.
-
Type the text shown here:
var f = this.getField("Today");
f.value = util.printd("mmm/d/yyyy", new Date());
NOTES:
Improper spacing in the text may affect results.
The
field reference must match the name you assigned to the text box in step 7 of Inserting the Date Field.
The date format must match the format you selected in step 10 of Inserting the Date Field.
-
Click OK
-
Click OK
The JavaScript is added.
-
From the file menu » select Save As...
The Save As dialog box appears.
-
Using the Save in pull-down list, select a save location
-
In the File name text box, type the file name
-
Click SAVE
The PDF is saved with the JavaScript programmed into it
If you found solution then you can follow me and send me your Suggestion on Satishrana93@gmail.com