How to Add Separate Sender and Recipient Print Dates to a PDF Form
Question details
The user needs to record the exact date and time a PDF form is printed by the sender, and separately record the print date and time for the recipient, ensuring the sender's original date is not overwritten.

- Product
- Device & OS
- not provided
- Scenario
- Creating a fillable PDF form that tracks accurate printing timestamps for both the document creator and the final recipient without conflicts.
- Observed behavior
- Using a basic 'Will Print' document script overwrites all date fields every time the document is printed, failing to preserve the sender's original print date.
Ensure you are using a desktop PDF editor that supports form field creation and document-level JavaScript execution, as many mobile viewers cannot run these scripts reliably.
Use Conditional JavaScript for Separate Print Date Fields
Create distinct fields for the sender and recipient, and use a conditional script that checks if the sender's field is empty before applying a date.
By utilizing a conditional statement within your 'Will Print' script, you can ensure that the sender's print date is populated only once. The recipient's print date field can be configured to update every time a subsequent print action is triggered.
Open your PDF form in editing mode and create two distinct text fields. Name the first one "PrintDate" (for the sender) and the second one "RecipientPrintDate".
Navigate to the document's properties or JavaScript settings menu, and locate the document-level "Will Print" event trigger.
Enter a script that only writes the date if the field is empty: `if (this.getField("PrintDate").value == "") { this.getField("PrintDate").value = util.printd("mm/dd/yyyy HH:MM", new Date()); }`.
Below the sender's code in the same "Will Print" event, add the script to always update the recipient's field: `this.getField("RecipientPrintDate").value = util.printd("mm/dd/yyyy HH:MM", new Date());`.
Save the document and print it to PDF to verify the sender date populates. Print it a second time to ensure the sender date remains unchanged while the recipient date updates to the new time.

Manually Lock the Sender's Date Field After Printing
Set up a standard print date script, print the document once to generate the sender's timestamp, and then manually lock the field to prevent future modifications.
Edit and Manage PDF Forms Seamlessly with WPS Office
WPS Office provides a comprehensive suite of PDF editing tools, allowing you to easily create fillable forms, manage text fields, and configure document properties for your daily workflow.
- 1. Open your PDF in WPS Office: Launch WPS Office and open the PDF document you want to edit or turn into a form.
- 2. Access Form tools: Navigate to the 'Form' tab on the top ribbon to reveal the form creation and editing tools.
- 3. Insert Text Fields: Click on 'Text Field' and click anywhere on the document to place fields for your sender and recipient print dates.
- 4. Modify field properties: Right-click the inserted text fields to adjust their properties, such as making them read-only or renaming them for scripting purposes.

Frequently Asked Questions
Why isn't my Will Print script working when opened on a smartphone?
Many mobile PDF viewers have limited or no support for JavaScript, which includes document-level events like 'Will Print'. For forms relying on complex scripting, it is highly recommended to instruct users to open and print them on a desktop PDF application.
Can I format the print date differently in the JavaScript code?
Yes, you can customize the date format within the util.printd function. For example, changing the format string from "mm/dd/yyyy HH:MM" to "dd-mmm-yyyy" will output the date in a format like "25-Oct-2023".
How do I prevent users from manually editing the print date fields before printing?
You can protect the fields by opening the text field properties in your PDF editor and enabling the "Read Only" option. This ensures the fields can only be populated by the automated JavaScript trigger, preventing manual keystrokes.




