logo
search
Other PDF Issues

How to Add a Printed Date with JavaScript in Acrobat Pro DC

Steve KSteve K Oct 22, 2026 868 views

Question details

The user wants to configure Adobe Acrobat Pro DC to automatically insert the current print date onto a PDF document using a JavaScript script.

How to Add a Printed Date with JavaScript in Acrobat Pro DC
Product
Adobe Acrobat Pro DC
Device & OS
not provided
Scenario
Automating the insertion of a print date on a PDF document right before it is printed.
Observed behavior
The user is looking for the specific tools and JavaScript configuration steps within Acrobat Pro DC to achieve automated date stamping upon printing.
Before you start

Ensure that JavaScript execution is permitted in your application. Go to Edit > Preferences > JavaScript in Acrobat Pro DC, and verify that 'Enable Acrobat JavaScript' is checked.

Solution 1Recommended

Use Prepare Form and Document JavaScript to Add Print Date

This method utilizes a read-only text field and a 'Will Print' document script to populate the current date right before the PDF is sent to the printer.

Acrobat Pro DC supports powerful Document and Form JavaScripts. By attaching a small script to the 'Document Will Print' event, you can ensure that a designated text field always shows the exact date the document was actually printed.

1
Create a Date Field

Open your PDF in Acrobat Pro DC. Go to 'Tools' > 'Prepare Form'. Add a new Text Field exactly where you want the date to appear. Name it 'PrintDate' and check 'Read-Only' in the field properties so users cannot manually edit it.

2
Access Document Actions

Navigate to the 'Tools' menu, search for 'JavaScript', and open the JavaScript toolset. Click on 'Document Actions' from the top toolbar.

3
Add the 'Will Print' Script

In the Document Actions dialog, select 'Document Will Print' and click the 'Edit' button. This ensures the code only runs when a print job is initiated.

4
Insert the JavaScript Code

Enter the following script into the editor: `this.getField("PrintDate").value = util.printd("mm/dd/yyyy", new Date());` and click 'OK'.

5
Test the Configuration

Save the PDF, then press Ctrl+P (or Cmd+P on Mac) to print. Select a virtual printer (like Print to PDF) to verify that the 'PrintDate' field automatically updates to today's date.

Use Prepare Form and Document JavaScript to Add Print Date
Security Restrictions: JavaScript execution might be restricted by your organization's security policies or document trust settings. Always test scripts on a local copy of your document first.
Effortless PDF Editing

Easily Add Dates and Manage PDFs with WPS Office

While writing JavaScript in Acrobat can be overly complex for simple tasks, WPS Office offers a highly intuitive way to edit PDFs, manually insert dates, and manage your documents without needing to write any code.

  1. 1. Open your PDF in WPS Office: Launch WPS Office and open the target PDF document you wish to modify.
  2. 2. Navigate to the Edit tab: Click on the 'Edit' tab at the top toolbar to access all available PDF editing tools.
  3. 3. Insert a Text Box for the Date: Select 'Insert Text', click on the page where you want the date to appear, and manually type the current date.
  4. 4. Save or Print: Save your changes using the save icon, or go directly to the Print menu to print your updated document immediately.
Easily add text, dates, and watermarks to PDF files via a user-friendly interface.Fully compatible with standard PDF formats and Adobe Acrobat files.Lightweight and fast, avoiding heavy resource usage on your computer.Offers a comprehensive Office suite (Writer, Spreadsheet, Presentation, PDF) in one single application.
QA img-9

Frequently Asked Questions

Why isn't my JavaScript executing when I print in Acrobat Pro?

Your Acrobat preferences might have JavaScript disabled for security reasons. Check Edit > Preferences > JavaScript and ensure 'Enable Acrobat JavaScript' is checked. Additionally, confirm that the document's security settings do not restrict structural changes or script execution.

Can I format the printed date differently using JavaScript?

Yes. In the `util.printd()` function, you can modify the format string. For example, using 'dd-mmm-yyyy' will output a format like '15-Oct-2023', whereas 'yyyy/mm/dd' will output '2023/10/15'.

Will this JavaScript method work when others open the PDF in Adobe Acrobat Reader?

Yes, the script will execute in Acrobat Reader when the user prints the document, provided the text field and document script were already embedded using Acrobat Pro DC, and the user has JavaScript enabled in their Reader preferences.