PDF Printing Issues

How to Print Multiple Page Ranges in PDF Using Acrobat JavaScript

Nimra MalikNimra Malik Nov 5, 2026 869 views

Question details

The user wants to configure a form button within a PDF document to automatically print specific, non-consecutive page ranges (such as pages 3-6 and 9-11) using a JavaScript action.

How to Print Multiple Page Ranges Using Acrobat Button Script
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating an interactive PDF form button to streamline the printing process for specific document sections.
Observed behavior
Needs the precise JavaScript syntax to execute a print command that targets multiple specific page groups simultaneously.
Before you start

Ensure you have a PDF editor with form creation capabilities (such as Adobe Acrobat Pro) and verify that the target users will have the necessary permissions to execute JavaScript in their PDF viewer.

Solution 1Recommended

Add a JavaScript Action to a Form Button

Use the Acrobat JavaScript API to define print parameters and specify an array of page ranges to print when the user clicks the button.

Acrobat JavaScript uses zero-based indexing for document pages. This means the first page is index 0, the second page is index 1, and so forth. To print page 3, you must use index 2 in your script.

1
Access the Prepare Form Tool

Open your PDF document in Adobe Acrobat, navigate to the 'Tools' menu, and select 'Prepare Form' to enter form editing mode.

2
Add a Button Field

Click the 'Button' icon on the top toolbar and click on the page where you want to place the print button.

3
Open Button Properties

Right-click the newly created button, select 'Properties' from the context menu, and navigate to the 'Actions' tab.

4
Set the JavaScript Action

Under 'Select Trigger', choose 'Mouse Up'. Under 'Select Action', choose 'Run a JavaScript', and then click the 'Add' button.

5
Enter the Print Script

In the JavaScript Editor, enter the following code to print pages 3-6 and 9-11: var p = this.getPrintParams(); p.printRange = [[2, 5], [8, 10]]; this.print(p); Click 'OK' to save.

Add a JavaScript Action to a Form Button
Reader Printing Restrictions: Printing via JavaScript may be restricted in Acrobat Reader. The document must either have extended usage rights applied or the user must have a supported and trusted printer workflow enabled.

Easily Print Multiple Page Ranges in WPS PDF

If you want to avoid writing complex JavaScript code, WPS Office offers a straightforward, intuitive print dialog that allows you to print multiple custom page ranges effortlessly without requiring interactive form buttons.

  1. 1. Open Your PDF: Launch WPS Office and open the PDF document you wish to print.
  2. 2. Open the Print Dialog: Click the 'Print' icon located on the top toolbar or press the 'Ctrl + P' shortcut on your keyboard.
  3. 3. Select Custom Pages: In the Print dialog box, look for the 'Pages to Print' section and select the 'Custom' or 'Pages' option.
  4. 4. Enter Your Page Ranges: Type the specific page ranges you need, separated by commas (for example, type '3-6, 9-11').
  5. 5. Print the Document: Adjust any other necessary settings like copies or orientation, and click 'Print' to send the specific pages to your printer.
Input multiple custom page ranges (e.g., '3-6, 9-11') directly via the Print menuNo JavaScript coding or advanced form setup requiredSeamlessly view and print standard PDF documents with high fidelityFully compatible with Microsoft Office formats including Word, Excel, and PowerPoint
microsoft office alternative - wps office

Frequently Asked Questions

Why is my PDF JavaScript printing the wrong pages?

Acrobat JavaScript utilizes zero-based indexing. This means the engine counts the first page of the document as page 0. If you want to print page 5, you must specify index 4 in your code. Always subtract one from the actual page number.

Can I print non-consecutive PDF pages without using a script?

Yes. In most modern PDF viewers, including WPS PDF and Acrobat, you can manually open the Print menu (Ctrl + P) and enter non-consecutive ranges separated by commas, such as '1-3, 7-9', directly into the custom pages input field.

Why doesn't the print button work when opened in Acrobat Reader?

Acrobat Reader enforces strict security measures that often restrict JavaScript execution for printing. To allow the script to function in Reader, the document must be saved with extended usage rights using Acrobat Pro, or the user's environment must trust the action.

How do I format the printRange array for a single page?

To print a single page using the printRange parameter in Acrobat JavaScript, you still use an array of arrays. For example, to print only page 4 (index 3), your code would be: p.printRange = [[3, 3]];.