How to Set Double-Sided Printing via PDF Button Using JavaScript
Question details
The user wants to configure an interactive PDF form button to automatically trigger a double-sided (duplex) print job using JavaScript.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where users can click a specific button to print the document on both sides of the paper without manually adjusting the generic print dialog.
- Observed behavior
- The standard print command opens the default print dialog without forcing duplex printing. Custom JavaScript is required to define and pass the exact print parameters.
Ensure that the destination printer hardware actually supports automatic double-sided (duplex) printing, as JavaScript commands cannot override physical printer limitations.
Configure JavaScript for Duplex Printing in a PDF Button
Program your PDF form button with a specific JavaScript snippet to bypass standard print defaults and automatically request double-sided printing.
Interactive PDF form buttons can be customized using JavaScript to define specific print parameters. By binding a script to the button's 'Mouse Up' action, you can instruct Acrobat to send a duplex printing request directly to the printer.
Enter form editing mode in your PDF editor. Right-click the button you want to configure for printing and select 'Properties' from the context menu.
Navigate to the 'Actions' tab. Under the 'Select Trigger' dropdown, choose 'Mouse Up'. Under the 'Select Action' dropdown, choose 'Run a JavaScript', and click the 'Add' button.
In the JavaScript Editor window that appears, paste the following code to request short-edge duplex printing: var pp = this.getPrintParams(); pp.DuplexType = pp.constants.duplexTypes.DuplexFlipShortEdge; this.print(pp);
If your document layout is portrait and requires standard book-style binding, change 'DuplexFlipShortEdge' to 'DuplexFlipLongEdge' in the script before clicking 'OK' to save.

Print Double-Sided PDFs Effortlessly with WPS Office
Skip the complex JavaScript coding when you just need to print standard documents. WPS PDF provides an intuitive, built-in interface for managing advanced print settings, allowing you to easily toggle double-sided printing on both short and long edges.
- 1. Open Your PDF: Launch WPS Office and open your target PDF document.
- 2. Access the Print Dialog: Click on the 'Menu' button in the top left corner and select 'Print', or simply press Ctrl + P on your keyboard.
- 3. Select Duplex Options: In the print dialog box, check the 'Print on both sides of paper' option. Choose either 'Flip on long edge' or 'Flip on short edge' depending on your layout, and click 'Print'.

Frequently Asked Questions
Why isn't my PDF button printing double-sided even with the correct JavaScript code?
The JavaScript code only sends a parameter request to the printer. If the selected printer lacks physical duplex capabilities or if duplex printing is restricted in the operating system's printer driver settings, the command will be ignored and it will print single-sided.
What is the difference between short-edge and long-edge flipping?
Long-edge flipping binds the pages along the longer side of the paper (like a standard portrait book). Short-edge flipping binds them along the shorter side, which is typically used for landscape documents like presentation slides or calendars.
Will this JavaScript print button work in all PDF readers?
No, the 'this.getPrintParams()' JavaScript API is primarily supported by Adobe Acrobat and Adobe Reader. Many third-party PDF viewers, mobile apps, or browser-based PDF readers may not execute this specific script or pass the duplex parameter correctly.




