PDF Printing Issues

Create an Acrobat Button to Print Page Ranges from Checkboxes

Muhammad TalhaMuhammad Talha Nov 19, 2026 868 views

Question details

Create an Acrobat form button that prints PDF page ranges according to selected checkboxes.

Create an Acrobat Button to Print Page Ranges from Checkboxes
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form contains checkboxes that determine which page ranges should be printed.
Observed behavior
The desired result is for only the print commands associated with selected checkboxes to run.
Before you start

Confirm that the PDF has the required checkbox fields and enough pages for the ranges you plan to print. Note each field name in Acrobat's Prepare a Form tool and test the script in a PDF viewer that supports Acrobat JavaScript.

Solution 1Recommended

Add a conditional print script to an Acrobat form button

Use this approach when each selected checkbox should trigger a specific page range.

Put every statement controlled by an if condition inside curly braces. Without braces, only the first following statement is conditional.

The example uses checkboxes named SectionA and SectionB and a PDF with at least four pages. Acrobat JavaScript uses zero-based page indexes, so 0–1 means PDF pages 1–2.

1
Check the form fields

Open the PDF in Acrobat and choose All tools > Prepare a form. Check the checkbox field names in their Properties, or rename them SectionA and SectionB for the example.

2
Add a button action

In Prepare a form, add or select a button and open its Properties. On the Actions tab, choose Mouse Up as the trigger and Run a JavaScript as the action, then select Add.

3
Enter the script

In the JavaScript editor, enter the following text, then save the action and button properties: var a = this.getField("SectionA"); var b = this.getField("SectionB"); if (!a || !b) { app.alert("Check the checkbox field names."); } else if (this.numPages < 4) { app.alert("This example requires at least four pages."); } else if (a.value === "Off" && b.value === "Off") { app.alert("Select at least one section."); } else { if (a.value !== "Off") { this.print({bUI: true, nStart: 0, nEnd: 1}); } if (b.value !== "Off") { this.print({bUI: true, nStart: 2, nEnd: 3}); } }

4
Test each selection

Save the PDF, exit form editing, and click the button with each checkbox selected individually and then with both selected. Check the ranges in the print dialogs before confirming them.

Add a conditional print script to an Acrobat form button
Print dialogs and page indexes: Selecting both checkboxes calls print twice, which can produce two print dialogs or jobs. Adjust the zero-based nStart and nEnd values to match your PDF, and verify the range in each dialog because print settings can be changed there.
Free Microsoft Office alternative

Print PDF Page Ranges Manually with WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office files. It can help you print selected PDF pages manually, but it does not replace the Acrobat JavaScript button described above.

Select PDF pages or ranges in the print dialogCompatible with Microsoft Word, Excel, and PowerPoint formatsFamiliar editing interface for an easier transition from Microsoft OfficeLightweight office suite with free tools
microsoft office alternative - wps office

Frequently Asked Questions

Why does a print command run when its checkbox is not selected?

Check the if statement in the button's JavaScript. Without curly braces, only the first statement immediately after the condition is controlled by it; put all related statements between { and }.

How do I find a checkbox's field name?

In Acrobat, open All tools > Prepare a form, select the checkbox, and open its Properties. Use its field name exactly in the script's this.getField call.

Why does the script use 0 for the first page?

Acrobat JavaScript page indexes start at 0. For example, nStart: 0 and nEnd: 1 specify the first and second PDF pages.

Can I print both checkbox ranges in one job?

The example calls this.print once for each selected checkbox, so it can create separate dialogs or jobs. For a manual single job, choose File > Print and enter the desired ranges in the Pages field.