How to Print Selected PDF Pages as One File Using Checkboxes
Question details
The user wants to print specific pages of a PDF form as a single combined print job based on interactive checkbox selections.

- Product
- Device & OS
- not provided
- Scenario
- Using interactive checkboxes in a PDF form to dynamically select specific pages for printing without creating separate print queue jobs.
- Observed behavior
- Calling the print method individually for each selected checkbox results in multiple separate print jobs instead of one consolidated file.
Ensure your PDF editor supports JavaScript execution and that you have permission to edit the interactive form fields within the document.
Use JavaScript PrintParams to Combine Print Jobs
Create an array to collect selected page ranges and pass it to the getPrintParams method to send a single, combined print job.
When you call the print method multiple times, the printer spooler treats each call as a separate document. By collecting the target pages into an array first, you can define a custom print range and execute a single print command.
Open the JavaScript editor or the properties panel of the button where the print action is triggered.
Create an empty array to store the pages you want to print by typing: var pagesToPrint = [];
Add conditional statements to check the value of each checkbox and push the corresponding page index to the array. For example: if (this.getField("page 1").value == "Yes") pagesToPrint.push([2,2]);
Check if the array has items, then retrieve the print parameters and assign the array to the printRange property: var pp = this.getPrintParams(); pp.printRange = pagesToPrint;
Execute the combined print command using the configured parameters: this.print(pp);

Edit Interactive PDF Forms with WPS Office
WPS PDF provides robust tools for creating, editing, and managing interactive PDF forms. You can easily add checkboxes, buttons, and configure advanced print settings all in one place.
- 1. Open your PDF: Launch WPS Office and open your interactive PDF document.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access interactive form controls.
- 3. Manage Form Fields: Add, modify, or configure your checkboxes and interactive buttons as needed.
- 4. Print Custom Ranges: Use the Print dialog (Ctrl+P) to manually select and manage print ranges if scripting is not required.

Frequently Asked Questions
Why are my PDF pages printing as separate jobs?
If a script triggers the print function individually for each selected page, the printer queue treats each trigger as a standalone job. Combining the page ranges into a single print command array resolves this issue.
Can I manually select discontinuous pages to print without scripting?
Yes. In the WPS PDF print dialog, you can enter specific page numbers separated by commas (e.g., 1, 3, 5) in the 'Pages' field to print them together as one continuous job.
Are PDF JavaScript page numbers zero-based?
Yes, when scripting in PDFs, page 1 is generally referred to as index 0, page 2 as index 1, and so forth. Always check your specific script logic to ensure the correct pages are targeted when using the push method.




