PDF Editing Issues

How to Make an Acrobat PDF Form Button Attach a File Directly

John WilsonJohn Wilson Nov 2, 2026 870 views

Question details

The user wants to configure a button in a PDF form to immediately open a file browser and attach a document, and requires this functionality to work for standard PDF Reader users.

How to Make an Acrobat PDF Form Button Attach a File Directly
Product
Adobe Acrobat / PDF
Device & OS
not provided
Scenario
Creating an interactive PDF form where end-users need to upload or attach supporting documents easily.
Observed behavior
Clicking the form button only opens the Attachments pane. Directly attaching files via JavaScript fails because it is restricted as a protected security operation.
Before you start

Ensure you have access to a professional PDF editor with form scripting capabilities, and verify that your document security settings permit modifications and annotations.

Solution 1Recommended

Use a JavaScript File Attachment Annotation

Since directly attaching files is a protected operation, you can bypass this limitation by using a form script to create a File Attachment annotation, which prompts the user with a file browser.

PDF scripts cannot normally perform protected attachment operations directly due to security restrictions. However, creating a FileAttachment annotation object is permitted and achieves the desired file browser prompt.

1
Open Prepare Form Mode

Open your document in Adobe Acrobat, navigate to the Tools menu, and select 'Prepare Form'.

2
Access Button Properties

Right-click the button you want to use for attachments and select 'Properties'.

3
Add a JavaScript Action

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

4
Enter the Annotation Script

In the JavaScript Editor, enter the following code: this.addAnnot({type:"FileAttachment", rect:[200,200,200,200], page:0});

5
Adjust Coordinates

Modify the 'rect' values [left, bottom, right, top] and the 'page' index (starting from 0) to position the attachment icon where you want it on the page.

Test the Button: Exit form editing mode and click the button to verify that the file browser opens successfully.
Simplify PDF Editing

Easily Add Attachments to PDFs with WPS Office

If writing JavaScript or configuring enterprise reader permissions is too complex, WPS Office provides a straightforward, user-friendly interface to embed files into your PDFs without any coding.

  1. 1. Open WPS Office: Launch WPS Office and open the PDF document you want to edit.
  2. 2. Navigate to the Comment Tab: Click on the 'Comment' tab located on the top ribbon.
  3. 3. Select the Attachment Tool: Find and click the 'Attachment' icon in the toolbar.
  4. 4. Place the Attachment: Click anywhere on the document page where you want the attachment pin to appear.
  5. 5. Choose Your File: A file browser will open automatically. Select the document you wish to attach and confirm.
Attach files with a single click without writing JavaScriptFully compatible with standard Adobe PDF formatsLightweight software with an intuitive, familiar interface
microsoft office alternative - wps office

Frequently Asked Questions

Why does my Acrobat form button only open the attachments pane?

Direct attachment operations are classified as protected operations for security reasons to prevent malicious scripts from secretly attaching or accessing files. Standard scripts can only invoke the attachments pane unless you use a specific FileAttachment annotation workaround.

Can standard Adobe Reader users add attachments to forms?

Standard Adobe Reader users can only add attachments if the creator of the form has applied specific Reader-enabled permissions (specifically the EFModif permission), typically done using enterprise tools like AEM Forms.

What does the 'rect' array in the PDF attachment script mean?

The 'rect' array (e.g., [200,200,200,200]) defines the coordinates and size of the interactive attachment icon on the PDF page. It specifies the left, bottom, right, and top edges of the rectangle measured in points.