Other PDF Issues

How to Stop a PDF from Automatically Printing on Open (Remove JavaScript)

Maira MehtabMaira Mehtab Nov 2, 2026 869 views

Question details

The user needs to prevent a PDF document from automatically triggering the print dialog as soon as the file is opened.

How to Stop a PDF from Automatically Printing on Open
Product
PDF
Device & OS
not provided
Scenario
Opening a downloaded or received PDF document using a PDF reader or editor.
Observed behavior
The PDF automatically initiates the print process or opens the print dialog because of a document-level JavaScript action calling the print method.
Before you start

Ensure you trust the source of the PDF before interacting with it, as malicious embedded scripts can pose security risks to your device. You may want to disable JavaScript globally in your PDF viewer before investigating.

Solution 1Recommended

Remove Document-Level JavaScript in Acrobat

Use advanced PDF editing tools to inspect the document's scripts and delete the code that forces the automatic print dialog.

Authors sometimes embed a script (like this.print();) to ensure users immediately print a form or ticket. Removing this specific script stops the forced behavior without altering the rest of the document's content.

1
Open JavaScript Tools

Open your PDF file in Adobe Acrobat. Navigate to the 'Tools' menu, scroll down to the 'Customize' or 'Action Wizard' section, and select 'JavaScript'.

2
Inspect Document Scripts

Click on 'Document JavaScripts' in the toolbar. This will open a dialog box listing all scripts embedded at the document level.

3
Locate and Delete the Print Command

Review the listed scripts for commands such as 'this.print();'. Highlight the script causing the issue and click the 'Delete' button to remove it.

4
Save a Clean Copy

Go to 'File' > 'Save As' to save a new copy of your PDF. Reopen the newly saved file to verify that the automatic printing behavior has completely stopped.

Remove Document-Level JavaScript in Acrobat
Verification Tip: Always use 'Save As' rather than 'Save' to preserve the original file. This acts as a backup in case you accidentally delete a necessary interactive script.
Secure & Efficient PDF Editing

View and Manage PDFs Safely with WPS Office

WPS Office provides a comprehensive and secure PDF reader and editor. It allows you to safely view documents, strip out unwanted embedded scripts by flattening files, and easily manage your PDF tasks without unexpected interruptions.

  1. 1. Download WPS Office: Visit the official WPS website and download the free WPS Office suite, which includes a powerful PDF toolkit.
  2. 2. Open the PDF Securely: Launch WPS PDF and open your document. The secure environment helps you manage files without unwanted script executions.
  3. 3. Flatten and Save: To permanently remove the auto-print script, go to Menu > Print, select 'WPS PDF' as your printer, and save it as a fresh, clean document.
  4. 4. Edit Your New File: Use WPS PDF's built-in editing tools to add text, highlight content, or merge pages as needed.
Built-in secure reading modes to prevent malicious scriptsEasily print-to-PDF to flatten and remove embedded JavaScriptFully compatible with all standard PDF formats and Adobe filesLightweight, fast, and completely free to use for basic tasks
QA img-9

Frequently Asked Questions

Why would an author add an auto-print JavaScript to a PDF?

Authors often embed 'this.print();' scripts in documents like event tickets, shipping labels, or official forms to ensure the user immediately prints the document upon opening, streamlining the process.

Is it dangerous to open a PDF with embedded JavaScript?

While auto-print scripts are generally harmless, embedded JavaScript can be used maliciously to execute harmful code on your device. It is recommended to only open interactive PDFs from trusted sources and keep your PDF reader updated.

Can I permanently disable JavaScript in my PDF reader?

Yes. Most major PDF readers, including Adobe Acrobat, allow you to turn off JavaScript globally. In Acrobat, you can do this by going to Edit > Preferences > JavaScript, and unchecking 'Enable Acrobat JavaScript'.

Will removing the JavaScript affect the rest of the PDF?

If you only remove the specific print command (like this.print();), the visual content of the PDF will remain entirely unchanged. However, if you flatten the PDF to remove it, other interactive elements like fillable form fields will also be removed.