How to Automatically Fill PDF Form Fields from Plain Text on Another Page
Question details
The user wants to automatically extract plain text (such as a person's name) from one page of a PDF and insert it into a form field on another page, like a cover letter.

- Product
- Adobe Acrobat Pro 2017
- Device & OS
- not provided
- Scenario
- Automating document generation by pulling existing, non-form plain text from a source page and displaying it inside a designated destination form field.
- Observed behavior
- Because the source text is plain text and not stored in a form field, standard field duplication methods do not work, requiring a custom script to locate and extract the text.
Verify that the plain text you want to extract consistently appears in a fixed location or follows a strict formatting pattern, as a custom script will need a reliable way to find it.
Use Acrobat JavaScript to Extract and Fill Text
Write a custom document-level JavaScript using the doc.getPageNthWord() function to parse page text and assign it to your target form field.
Since standard PDF form field linking only works when both the source and destination are form fields, pulling plain text requires a script. The Acrobat JavaScript API allows you to programmatically read words directly from the document pages.
To make this work seamlessly, your script must be able to accurately identify the target text. This means the text must be located at specific coordinates, be preceded by a unique label (like 'Name:'), or have a highly unique structure.
In Adobe Acrobat Pro, open your PDF and navigate to 'Tools' > 'JavaScript'. Click on 'Document JavaScripts' or create a custom button to trigger a 'Run a JavaScript' action.
Identify the page number where the source text resides. Note that the JavaScript API uses zero-based indexing, meaning the first page is page 0.
Write a script that loops through the text using the doc.getPageNthWord(pageNum, wordIndex) function. Add logic to find your specific word or phrase based on the predefined format or unique label.
Once the script isolates the desired string, assign it to the destination form field using the syntax: this.getField('YourTargetFieldName').value = extractedString;

Simplify PDF Form Creation and Text Management with WPS PDF
If you want to avoid writing complex JavaScript code for standard document setups, WPS PDF offers intuitive tools to create interactive form fields and easily manage text across pages.
- 1. Open Your PDF: Launch WPS Office and open your PDF document using the built-in WPS PDF editor.
- 2. Access the Form Tab: Navigate to the 'Form' tab on the top ribbon to access the interactive form creation suite.
- 3. Create Matched Fields: Click 'Text Field' and place fields in both your source area and your destination (like the cover letter). Give both fields the exact same 'Name' in their properties.
- 4. Auto-Fill Across Pages: By using matched form fields instead of plain text, typing a name in the source field will instantly and automatically duplicate it in the cover letter field.

Frequently Asked Questions
Can I automatically link two PDF fields to show the same text?
Yes. If the source text is entered into a form field rather than existing as plain text, you can easily auto-fill the destination field. Simply open the properties of both text fields and give them the exact same Field Name. When a user types in one, the other updates automatically.
Is there a non-scripting method to extract plain text into a PDF form field?
No. Without using JavaScript or an external data extraction tool, PDF software cannot automatically distinguish or pull standard plain text from a page into a form field. Manual copying or restructuring the document to use form fields for data entry is required.
What does doc.getPageNthWord() do in PDF scripting?
It is an Acrobat JavaScript API function that allows scripts to read the contents of a PDF page word by word. You provide the page number and the word's index, and it returns the specific text string, which can then be processed or placed into form fields.




