PDF Editing Issues

How to Open an Attached PDF from a Drop-Down Field Using JavaScript in Acrobat

Natalie TaylorNatalie Taylor Nov 2, 2026 869 views

Question details

The user needs to use a JavaScript calculation script to automatically open an embedded PDF file when a specific option is selected from a drop-down field.

How to Open an Attached PDF from a Drop-Down Field Using JavaScript
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Triggering the opening of an attached or embedded PDF file upon selecting a specific value from a drop-down menu within a PDF form.
Observed behavior
The JavaScript code fails to execute and open the attachment because property names, specifically 'nLaunch', are case-sensitive and were incorrectly capitalized.
Before you start

Ensure that your primary PDF already contains the embedded file attachment and that your environment allows JavaScript execution for interactive PDF forms.

Solution 1Recommended

Correct the Capitalization of the nLaunch Property

Fix the syntax of your JavaScript code by using the correctly capitalized property name 'nLaunch' to ensure the embedded file opens properly.

Acrobat JavaScript is strictly case-sensitive. When using the exportDataObject method to open an embedded attachment, the property parameter must be capitalized exactly as required by the API. Using 'nlaunch' instead of 'nLaunch' will cause the script to fail quietly.

1
Access Drop-Down Properties

Open your PDF form in Adobe Acrobat, right-click the target drop-down field, and select 'Properties'.

2
Edit the Calculation Script

Navigate to the 'Calculate' tab, select 'Custom calculation script', and click 'Edit'.

3
Apply Correct Syntax

Input the script using the correct capitalization: if (event.value == "Your Target Value") this.exportDataObject({cName: "your-attachment.pdf", nLaunch: 2});

4
Verify Attachment Name

Ensure that the value assigned to 'cName' exactly matches the file name of the embedded PDF, including the .pdf extension.

5
Save and Test

Click 'OK' to save the script, exit form editing mode, and select the value from the drop-down to test if the attached PDF opens successfully.

Correct the Capitalization of the nLaunch Property
Security Prompt: Depending on Acrobat's trust settings, opening an attachment via JavaScript may trigger a security warning prompt. The user will need to grant permission to launch the file.
Easily Manage PDF Forms and Attachments

Manage PDF Forms and Attachments with WPS Office

WPS Office provides a comprehensive PDF editor that allows you to effortlessly view, manage attachments, and interact with PDF forms without needing complex JavaScript debugging.

  1. 1. Download and Install: Download WPS Office Free and install it on your device.
  2. 2. Open Your PDF: Launch WPS PDF and open the document containing the form fields or attachments.
  3. 3. Access Attachments Directly: Click on the 'Attachment' pane on the left sidebar to instantly view and open any embedded files without relying on scripts.
  4. 4. Interact with Forms: Navigate to the 'Form' tab to seamlessly fill out drop-down fields and other interactive elements.
Create, view, and interact with standard PDF forms effortlessly.Easily extract, view, and manage embedded PDF file attachments.Fully compatible with standard PDF formats and interactive elements from Adobe Acrobat.Lightweight alternative with an intuitive and user-friendly interface.
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't my Acrobat JavaScript opening the attached PDF?

The most common reason is incorrect capitalization of JavaScript properties. Ensure you are using 'nLaunch' instead of 'nlaunch', and verify that the attachment name defined in 'cName' matches the actual embedded file perfectly.

What does 'nLaunch: 2' do in the exportDataObject method?

In Acrobat JavaScript, setting 'nLaunch: 2' instructs the application to save the extracted embedded file to a temporary location and immediately open it using the default system application associated with that file type.

Can I open an embedded file from a button click instead of a drop-down?

Yes. You can attach the same exportDataObject JavaScript code to the 'Run a JavaScript' action under the 'Mouse Up' trigger within a button's properties.