How to Make an Acrobat PDF Form Button Attach a File Directly
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.

- 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.
Ensure you have access to a professional PDF editor with form scripting capabilities, and verify that your document security settings permit modifications and annotations.
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.
Open your document in Adobe Acrobat, navigate to the Tools menu, and select 'Prepare Form'.
Right-click the button you want to use for attachments and select 'Properties'.
Go to the 'Actions' tab, select 'Run a JavaScript' from the Select Action dropdown, and click 'Add'.
In the JavaScript Editor, enter the following code: this.addAnnot({type:"FileAttachment", rect:[200,200,200,200], page:0});
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.
Enable Reader Permissions via AEM Forms
If standard Adobe Reader users need to add or remove attachments, the PDF must be saved as a Reader-enabled form with specific advanced permissions.
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. Open WPS Office: Launch WPS Office and open the PDF document you want to edit.
- 2. Navigate to the Comment Tab: Click on the 'Comment' tab located on the top ribbon.
- 3. Select the Attachment Tool: Find and click the 'Attachment' icon in the toolbar.
- 4. Place the Attachment: Click anywhere on the document page where you want the attachment pin to appear.
- 5. Choose Your File: A file browser will open automatically. Select the document you wish to attach and confirm.

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.




