How to Automatically Print the Current Date in an Acrobat PDF Form
Question details
The user needs a copied PDF form to automatically generate and print the current date, replicating the behavior of the original PDF document.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Setting up a copied PDF form so that it dynamically inserts the current date and time upon printing.
- Observed behavior
- The copied PDF form fails to print the current date because the required document-level JavaScript and specific field visibility settings were not transferred from the original file.
Ensure you have a PDF editor with form editing capabilities, such as Adobe Acrobat Pro, to access document-level JavaScript and form field properties.
Transfer Document Actions and Field Settings
Copy the document-level JavaScript from the original PDF to the new file and ensure the date field is set to be visible only when printing.
When you copy a form field from one PDF to another, document-level scripts do not automatically carry over. You must manually add the JavaScript to the new document's 'Will Print' action to trigger the dynamic date generation right before the document is sent to the printer.
Open your new PDF form in preparation mode. Ensure you have a text field explicitly named 'Date' (or 'Time' if you are inserting the current time). The field name must perfectly match the script.
Right-click the 'Date' field and select 'Properties'. Under the 'General' tab, look for the 'Form Field' or 'Visibility' property and set it to 'Hidden but printable' (or 'Print Only'). This ensures the date doesn't show up blank on the screen but appears when printed.
Go to the 'Tools' menu, select 'JavaScript', and click on 'Document Actions' or 'Document JavaScripts'.
Select the 'Will Print' action and click 'Edit'. Paste the following script: var f = this.getField("Date"); if (f) f.value = util.printd("mm/dd/yyyy", new Date());
Click 'OK' to save the script. Close the JavaScript window and try printing the document (you can print to PDF to test) to verify that the current date appears successfully on the output.

Easily Manage and Edit PDF Forms with WPS Office
WPS Office features a robust built-in PDF editor that allows you to effortlessly view, fill, edit, and print PDF forms. Whether you need to insert text, add electronic signatures, or manage form fields, WPS PDF provides an intuitive interface for all your document needs.
- 1. Open your PDF in WPS Office: Launch WPS Office and open your existing PDF form file.
- 2. Edit or Fill the Form: Navigate to the 'Form' tab to interact with text fields, checkboxes, and dropdowns directly.
- 3. Add Custom Text or Dates: If dynamic scripts are not required, use the 'Insert' tab to easily place a text box with the current date anywhere on your document before printing.
- 4. Print the Document: Go to 'Menu' > 'Print' to configure your print settings and generate your finalized document with all filled data intact.

Frequently Asked Questions
Why did my JavaScript not transfer when I copied the PDF form?
Document-level JavaScripts, such as those triggered by the 'Will Print' action, are tied to the document itself, not individual form fields. When you copy fields to a new document, you must manually recreate the document-level scripts.
How do I hide a field on screen but show it when printing?
In the form field properties under the 'General' tab, change the visibility setting to 'Hidden but printable'. This ensures that fields, such as print timestamps, only appear on the physical or printed copy.
Can I print the exact time alongside the date in a PDF form?
Yes, you can add an additional script line for a time field. Ensure you have a field named 'Time', then add this to the Will Print action: var t = this.getField("Time"); if(t) t.value = util.printd("h:MM tt", new Date());




