Monday, May 25, 2015

Automatic Date Field in PDF

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

return to topInserting the Date Field

The date will appear as part of a text field.
  1. Open the PDF file that you will use the form for
  2. From the Forms menu, select Add or Edit Fields...
    Adobe Acrobat 9 Pro enters Form Editing mode and the Forms toolbar appears.
    Forms toolbar
  3. Click TEXT FIELD TOOLText Field Tool button
    HINT: The cursor changes to a cross hairs. The cross hairs allow you to align the field with the ruler, text, or another field.
  4. Position the cursor where you want the text field to begin 
  5. Click and drag the mouse until the text field reaches the desired size
  6. Release the mouse button
    The Field Name entry box appears.
    Field Name entry box
  7. 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.
  8. Click SHOW ALL PROPERTIES
    The Text Field Properties dialog box appears.
    Text Field Properties dialog box: General tab
  9. 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.
  10. On the Format tab
    1. From the Select format category pull-down list, select Date
    2. 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.
  11. Click CLOSE
    The date field is inserted.

return to topAdding the JavaScript

The javascript is applied to the page. Therefore, you must be out of Form Editing mode.
  1. If you are not out of Form Editing mode, click CLOSE FORM EDITINGClose Form Editing button
  2. From the Navigation pane, click PAGESPages button
    NOTES:
    The Pages pane opens.
    This action toggles between hiding and displaying the Pages pane.
  3. Right click the page thumbnail of your form that contains the Date field » select Page Properties...
    The Page Properties dialog box appears.
  4. Select the Actions tab
    Page Properties dialog box: Actions tab
  5. In the Add an Action section, from the Select Trigger pull-down list, select Page Open
  6. From the Select Action pull-down list, select Run a JavaScript
  7. Click ADD...
    The JavaScript Editor dialog box appears.
    JavaScript Editor dialog box
  8. 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.
  9. Click OK
  10. Click OK
    The JavaScript is added.
  11. From the file menu » select Save As...
    The Save As dialog box appears.
  12. Using the Save in pull-down list, select a save location
  13. In the File name text box, type the file name
  14. Click SAVE
    The PDF is saved with the JavaScript programmed into it

  15. If you found solution then you can follow me and send me your Suggestion on Satishrana93@gmail.com