Other PDF Issues

Troubleshoot an Acrobat JavaScript Button That Cannot Add PDF Attachments

Steven ParkerSteven Parker Nov 25, 2026 868 views

Question details

Determine why an Acrobat JavaScript button does not add a selected file as a PDF attachment annotation.

Troubleshoot an Acrobat JavaScript Button That Cannot Add PDF Attachments
Product
Adobe Acrobat JavaScript
Device & OS
not provided
Scenario
A custom Add PDF button should open a file browser and create a FileAttachment annotation for the selected file.
Observed behavior
Clicking the button appears to do nothing.
Before you start

Open the PDF and locate the Add PDF button's JavaScript in Acrobat. Identify the button action and any custom dialog code so you can test the file browser and annotation creation separately.

Solution 1Recommended

Isolate the Acrobat file browser and attachment annotation

Use a minimal test to identify whether the button, file selection, or annotation creation is failing.

1
Check the button action

Open the button's properties in Acrobat and check the Actions tab for the JavaScript associated with the click. Temporarily remove unrelated custom dialog code from a test version of the script.

2
Inspect JavaScript errors

Open the Acrobat JavaScript console, clear existing messages, and click the Add PDF button. Check for errors or a test message confirming that the button action ran.

3
Test file selection

Run a minimal test of app.browseForDoc() from the relevant button action. Select a file and inspect the returned result in the JavaScript console to confirm that it contains a usable file path.

4
Test annotation creation

Test addAnnot() separately with a known file path and the properties required for a FileAttachment annotation. Check the JavaScript console and the PDF page to see whether the annotation is created.

5
Restore the full script

Once both tests work, add the custom dialog and remaining code back in stages. Click Add PDF after each change to identify the operation that causes the failure.

Isolate the Acrobat file browser and attachment annotation
Check security and permissions: Acrobat JavaScript operations can be subject to security restrictions and document permissions. If the console reports a security or permission error, check the relevant Acrobat JavaScript documentation and the PDF's permissions.
Free Microsoft Office alternative

Work with PDFs and Office files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office files. Its format compatibility helps make migration straightforward, although it does not troubleshoot Acrobat JavaScript.

Open and review PDF documents alongside Office filesCompatible with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXFamiliar interface for moving between document tasksFree, lightweight suite for everyday office work
microsoft office alternative - wps office

Frequently Asked Questions

How can I tell whether the Add PDF button runs its script?

Check the button's Actions tab in Acrobat to confirm that a JavaScript action is assigned. Add a temporary test message, then click the button and check the JavaScript console.

What should I check if the file browser does not open?

Test app.browseForDoc() on its own from the button action and inspect the Acrobat JavaScript console for errors. Also check whether the operation is restricted by the execution context or security settings.

What if I can select a file but no attachment appears?

Inspect the result returned by app.browseForDoc(), then test addAnnot() separately with a known file path and the required FileAttachment properties. Check the console for errors and the target PDF page for the annotation.

Can WPS Office fix an Acrobat JavaScript error?

No. Troubleshoot Acrobat-specific JavaScript in Acrobat using its button properties, JavaScript console, and documentation. WPS Office is an alternative for general PDF and Office file work.