Fix Incorrect AM/PM Time Format in PDF Will Print Action
Question details
The user needs to correct an issue where a PDF's JavaScript displays the wrong AM/PM indicator during a print action.

- Product
- Adobe Acrobat / Chrome PDF Viewer
- Device & OS
- not provided
- Scenario
- Executing JavaScript to populate a 12-hour time format field during a PDF 'Will Print' action.
- Observed behavior
- The 12-hour format and AM/PM indicators display correctly when saving the document, but the AM/PM value becomes incorrect when printing the file through Google Chrome.
Ensure your JavaScript code accurately utilizes standard date and time formatting methods before investigating browser-specific rendering bugs.
Print Using a Dedicated Desktop PDF Application
Bypass browser plugin limitations by opening and printing the interactive PDF using a native desktop PDF reader.
Google Chrome's built-in PDF viewer uses a different JavaScript rendering engine than dedicated PDF software. This often leads to misinterpretations of specific Acrobat JavaScript methods, such as date object formatting during the 'Will Print' event.
Save the PDF file from Google Chrome to your local hard drive instead of printing it directly from the browser window.
Right-click the downloaded PDF file, select 'Open with', and choose a dedicated application like Adobe Acrobat, Acrobat Reader, or WPS PDF.
Click the 'Print' icon or press Ctrl+P. The native software will correctly process the 'Will Print' JavaScript, ensuring the AM/PM format remains accurate.

Report the Bug to the Browser Developers
If you are designing a PDF for users who primarily use Google Chrome, notify the developers to get the plugin patched.
Print Interactive PDFs Reliably with WPS PDF
Avoid unpredictable browser-based JavaScript errors by managing your interactive PDF forms directly in WPS Office. WPS PDF offers native handling of form actions and scripts, ensuring time formats are printed flawlessly.
- 1. Open Your PDF in WPS: Launch WPS Office and open the PDF document containing your custom time-formatting JavaScript.
- 2. Verify the Document: Check that any dynamic fields display the correct initial 12-hour format and AM/PM values.
- 3. Trigger the Print Menu: Click the Print icon on the top toolbar or press Ctrl+P to open the print dialog and trigger the 'Will Print' script.
- 4. Print the Document: Select your physical printer or 'Print to PDF' and click 'Print'. WPS PDF will correctly process the script and output the accurate time.

Frequently Asked Questions
Why does my Acrobat JavaScript work when saving but fail when printing in Chrome?
When you save a PDF, the action is usually executed by the native software's engine. When printing from Google Chrome, the action relies on Chrome's built-in PDF rendering plugin, which may misinterpret specific JavaScript date and time string conversions during the print spooling phase.
How do I correctly format a 12-hour clock with AM/PM in Acrobat JavaScript?
You can use the built-in utility method `util.printd("h:MM tt", new Date())` within Acrobat JavaScript. This securely formats the current date object into a 12-hour time string with the correct AM or PM indicator.
Can I force Google Chrome to use a desktop app for printing PDFs?
Yes. You can bypass the Chrome PDF viewer entirely by going to Chrome Settings > Privacy and security > Site Settings > Additional content settings > PDF documents. Select 'Download PDFs' to force the browser to download the files so they can be opened and printed in a dedicated desktop app like WPS PDF.




