PDF Editing Issues

Get PDF Form Field Names by Page Range in Adobe Acrobat

Rana GarciaRana Garcia Nov 18, 2026 868 views

Question details

Find PDF form field names that appear within a specified page range.

Get PDF Form Field Names by Page Range in Adobe Acrobat
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A user wants to identify fields on selected PDF pages before populating them with Acrobat JavaScript.
Observed behavior
doc.numFields counts fields across the entire document rather than only the selected pages.
Before you start

Open the PDF in Adobe Acrobat and make sure JavaScript is enabled in Acrobat's Preferences. Identify the first and last pages you want to inspect; the script below accepts the page numbers shown in the document.

Solution 1Recommended

Filter PDF Form Fields by Page with Acrobat JavaScript

Use the JavaScript console to collect field names whose page property overlaps the requested range.

Acrobat page indexes are zero-based, so the script converts the displayed page numbers before comparing them. A field's page property can be a number or an array when the field appears on multiple pages.

1
Open the JavaScript console

With the PDF open in Acrobat, open the JavaScript console. On Windows, use Ctrl+J; console availability depends on your Acrobat product and settings.

2
Set the page range

Paste the following script into the console and replace 2 and 4 with the first and last displayed page numbers you want to include: var doc = this; var firstPage = 2; var lastPage = 4; var names = []; for (var i = 0; i < doc.numFields; i++) { var name = doc.getNthFieldName(i); var field = doc.getField(name); if (!field) continue; var pages = field.page; if (typeof pages === "number") pages = [pages]; if (!pages) continue; for (var j = 0; j < pages.length; j++) { if (pages[j] >= firstPage - 1 && pages[j] <= lastPage - 1) { names.push(name); break; } } } console.println(names.join("\n"));

3
Run and review the results

Select the script in the console and execute it. On Windows, press Ctrl+Enter or the numeric keypad Enter key. Review the printed names and use the names array in your field-population script.

Filter PDF Form Fields by Page with Acrobat JavaScript
Fields on multiple pages: A field name is added once if any of its page indexes falls within the range. The results identify matching field names, not individual widget instances.
Free Microsoft Office alternative

Work with PDF Forms and Office Files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface and Microsoft Office format compatibility for an easy transition. Its PDF tools can help you work with forms, but the Acrobat JavaScript filtering method above must be run in Acrobat.

Work with PDF forms alongside documents and spreadsheetsOpen and edit Microsoft Word, Excel, and PowerPoint formatsUse a familiar interface to make migration easierKeep everyday office tools in one lightweight suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does doc.numFields include fields outside my page range?

doc.numFields counts fields in the whole PDF. Loop through the names with doc.getNthFieldName(i), retrieve each field with doc.getField(name), and filter by field.page.

Are Acrobat JavaScript page indexes zero-based?

Yes. The first page has index 0, so subtract 1 from the displayed page number before comparing it with field.page.

How do I handle a field that appears on multiple pages?

Check whether field.page is a number or an array. If it is an array, inspect each page index and include the field name when at least one index is in the requested range.

Will the script list each occurrence of a repeated field separately?

No. It adds the field name once when any associated page matches. A field with the same name on multiple pages may have multiple widget instances.