Other PDF Issues

How to Populate One PDF from Another Using Acrobat JavaScript

Algirdas JasaitisAlgirdas Jasaitis Oct 28, 2026 869 views

Question details

The user needs to automatically transfer form data from one PDF document to another using JavaScript.

How to Populate One PDF from Another Using Acrobat JavaScript
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Transferring form data between documents when a user selects a checkbox or opens a second file.
Observed behavior
Requires correct configuration of field names, document paths, and utilization of the openDoc API method while managing PDF security restrictions.
Before you start

Ensure both PDF documents are saved in the same local directory or a trusted folder, as cross-document JavaScript execution is often restricted by default security settings.

Solution 1Recommended

Use the openDoc Method to Transfer Form Data

The most reliable way to pull data from another PDF is by using the JavaScript API's app.openDoc() method to access the source document's fields and extract their values.

Cross-document interactions in PDFs require both documents to be accessible to the script. The app.openDoc() method allows the current destination document to open a secondary source document in the background and read its field values.

Depending on your software's security settings, this method may require you to configure folder-level scripts or create a trusted function to bypass cross-file restrictions.

1
Enter form editing mode

Open your destination PDF in your PDF editor, navigate to the Tools menu, and select 'Prepare Form' or 'Form Editing' mode.

2
Access field properties

Right-click the trigger element, such as a checkbox or button, and select 'Properties' from the context menu.

3
Add a JavaScript action

Go to the 'Actions' tab, choose 'Run a JavaScript' from the Select Action dropdown, and click the 'Add' button.

4
Write the openDoc script

Input the JavaScript code using app.openDoc('source.pdf') to open the source file. Map the data by adding: this.getField('TargetField').value = sourceDoc.getField('SourceField').value;

5
Save and test the form

Click 'OK' to save the script, exit form editing mode, and test the trigger to ensure the data populates correctly.

Use the openDoc Method to Transfer Form Data
Security Restrictions: If the files are not stored in a Privileged Location, the openDoc method may fail silently or throw a security exception. You may need to adjust your enhanced security preferences.
Powerful PDF Form Management

Easily Manage and Edit PDF Forms with WPS Office

While advanced cross-document JavaScript requires specialized scripting and security bypasses, WPS Office provides an intuitive, comprehensive PDF editor that allows you to easily create, edit, fill, and manage PDF forms without complex code.

  1. 1. Open your PDF: Download and launch WPS Office, then open your PDF document containing the forms.
  2. 2. Access the Form tab: Navigate to the 'Form' tab on the top ribbon to access the interactive form field tools.
  3. 3. Edit or fill fields: Click on 'Text Field', 'Checkbox', or other elements to manually insert or edit form data without needing external scripts.
  4. 4. Merge documents safely: If you need data from multiple files, use the 'Merge PDF' tool to combine multiple forms into a single file, completely avoiding cross-document scripting issues.
Fully compatible with standard PDF forms and interactive fieldsEdit text, insert images, and combine PDF pages effortlesslyLightweight, fast, and completely free to download
microsoft office alternative - wps office

Frequently Asked Questions

Why does the app.openDoc() method fail to open the second PDF?

This usually occurs due to enhanced security settings in modern PDF readers. Both files must be located in a 'Privileged Location' or 'Trusted Folder', or the script must be executed via a trusted folder-level function.

Can I transfer PDF form data without using JavaScript?

Yes, you can manually export form data as an FDF or XML file from the source PDF via the Form settings, and then import that data file into the destination PDF using the 'Import Data' feature.

How do I trigger the JavaScript as soon as the PDF opens?

You can assign the JavaScript action to the 'Page Open' event under the document's Page Properties, or set it up as a Document-Level script that executes upon file initialization.