PDF Editing Issues

Merge PDF Form Fields with Adobe Acrobat JavaScript

Huma Ashraf ChHuma Ashraf Ch Nov 19, 2026 868 views

Question details

Combine name and address fields from a source PDF form into fields in a service agreement or renewal form.

Merge PDF Form Fields with Adobe Acrobat JavaScript
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A user wants to transfer and concatenate values from one PDF form into another using Acrobat JavaScript.
Observed behavior
The destination form should contain combined text from the corresponding source fields.
Before you start

Open both forms in Acrobat and check their exact field names in Prepare a Form. Confirm that JavaScript is enabled and that you have permission to edit the forms.

Solution 1Recommended

Use an Acrobat button to combine source PDF fields

Use this method when you can edit both forms and want a button to populate the destination address field.

The source document must be disclosed before another document can access its fields. Use valueAsString to combine field values as text.

The example joins address fields with commas. Empty fields will still produce separators, so adjust the script if you want to omit them.

1
Disclose the source form

In the source PDF, open All tools > Use JavaScript > Document JavaScripts, add a script containing this.disclosed = true;, and save the PDF.

2
Check the field names

Open Prepare a Form in each PDF and verify the source names Address_1, Address_2, Suburb, State, and Postcode, as well as the destination name Address. Correct any spelling differences in the script.

3
Add a button action

In the destination PDF, open Prepare a Form and add or select a button. In its Properties > Actions tab, select Mouse Up, choose Run a JavaScript, and click Add.

4
Enter the script

Enter the following script, replacing the filename or field names as needed: var cData = app.openDoc("EPM Service Request V4.pdf"); this.getField("Address").value = cData.getField("Address_1").valueAsString + ", " + cData.getField("Address_2").valueAsString + ", " + cData.getField("Suburb").valueAsString + ", " + cData.getField("State").valueAsString + ", " + cData.getField("Postcode").valueAsString;

5
Test the destination form

Save the destination PDF, exit form editing, and click the button. Check that the Address field contains the expected source values. For names, add a similar assignment using the exact source and destination name field names.

Use an Acrobat button to combine source PDF fields
Opening the source file: Acrobat security settings may restrict opening a file from a button script. If the source PDF cannot be found or opened, check its path and Acrobat's JavaScript security requirements; a trusted function may be needed in an authorized environment.
Free Microsoft Office alternative

Work with PDFs and Office documents in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. Its format compatibility makes it easier to move existing files into your workflow. Acrobat-specific JavaScript and security settings must still be handled in Acrobat.

Open and work with PDF documents alongside other filesCompatible with Microsoft Word, Excel, and PowerPoint formatsFamiliar interface for an easier transitionFree and lightweight for everyday document work
microsoft office alternative - wps office

Frequently Asked Questions

Why must the source PDF be disclosed?

Setting this.disclosed = true; in a document-level script allows other documents to access the source document's properties and fields, subject to Acrobat's security restrictions.

How do I find the exact PDF field names?

Open each PDF in Acrobat and choose Prepare a Form. Select the fields and inspect their properties, then use the exact names in the JavaScript.

Why does the button fail to open the source PDF?

Check the filename and path supplied to app.openDoc, and confirm that the source document is accessible. Acrobat security restrictions can also block the call; a trusted function may be required in an authorized environment.

Can I combine name fields as well as address fields?

Yes. In the button's Run a JavaScript action, add another assignment that joins the source name fields with valueAsString and writes the result to the destination name field. Use the exact field names from both forms.