PDF Printing Issues

How to Print Only PDF Form Pages That Contain User Data

Nimra MalikNimra Malik Nov 5, 2026 869 views

Question details

The user wants to print a multi-page PDF form, ensuring required pages are always printed, but optional pages are only printed if their associated fields contain user data.

How to Print Only PDF Form Pages That Contain User Data
Product
PDF
Device & OS
not provided
Scenario
Printing a long PDF form containing optional sections to avoid wasting paper on completely blank form pages.
Observed behavior
The user needs a way to dynamically evaluate which optional fields have data and adjust the document's print range accordingly before sending it to the printer.
Before you start

Ensure you are using a PDF editor that supports JavaScript execution and that you know the exact field names and page numbers (0-indexed) for the optional sections of your form.

Solution 1Recommended

Use JavaScript to Dynamically Set the Print Range

Create a custom print script that checks the value of specific form fields and builds an array of pages to print.

By utilizing the Acrobat JavaScript API within your PDF editor, you can script a custom print button that analyzes field values. If an optional field is not empty, its corresponding page is added to the print queue.

1
Initialize Print Parameters

Open the JavaScript console or the action settings of your custom print button. Start by getting the default print parameters using `var pp = this.getPrintParams();`.

2
Define the Print Array

Create an empty array to hold the page ranges you want to print, for example, `var printArray = [];`. Push your required page arrays into this list first.

3
Evaluate Optional Fields

Use `this.getField("YourFieldName").valueAsString` to retrieve the data from an optional field. Use an `if` statement to check if the value is not empty (`!== ""`).

4
Append Pages to the Range

If the field contains data, push its corresponding page number (e.g., `[3, 3]`) into your `printArray`.

5
Execute the Print Command

Assign the dynamically built array to the print parameters with `pp.printRange = printArray;`, and then trigger the print dialog using `this.print(pp);`.

Use JavaScript to Dynamically Set the Print Range
Zero-Based Indexing: Remember that page numbers in PDF JavaScript arrays are zero-based. Page 1 of your document is represented as 0, Page 2 is 1, and so on.
Efficient PDF Management

Manage and Print Specific PDF Pages with WPS Office

If scripting is too complex, WPS Office provides intuitive visual tools to extract pages with data and print exactly what you need without writing a single line of code.

  1. 1. Open Your PDF Form: Launch WPS Office and open your multi-page PDF form.
  2. 2. Fill the Required Fields: Complete the form fields as needed using the interactive PDF tools provided in the software.
  3. 3. Extract Filled Pages Visually: Navigate to the 'Page' tab and use the 'Extract' tool. Hold the Ctrl key and select only the required pages and the optional pages you just filled out.
  4. 4. Print the Customized Range: Once the filled pages are extracted into a new document, press Ctrl+P to open the Print dialog and print your customized document.
Easily extract or split PDF pages containing data before printingFully compatible with standard PDF forms and annotationsLightweight application with a user-friendly, familiar interfaceCross-platform support for Windows, Mac, iOS, and Android
QA img-9

Frequently Asked Questions

Can I print only filled form pages without using JavaScript?

Without JavaScript, you cannot perform this automatically. You will need to manually determine which pages contain data and specify those page numbers (e.g., 1-3, 5, 8) in the 'Pages to Print' section of your standard Print dialog.

Why isn't my JavaScript print button working in my web browser?

Most built-in PDF viewers in web browsers disable or do not fully support the Acrobat JavaScript API for security reasons. Users must open the PDF form in a dedicated desktop application to utilize dynamic printing scripts.

How do I find the specific names of my form fields to use in the script?

Open your PDF in form editing mode. Right-click the specific form field and select 'Properties'. The exact field name will be displayed in the General tab, which you can copy into your script.