How to Add a File Attachment Button to a PDF Form in Adobe Acrobat
Question details
The user wants to create a button within a PDF form that allows form fillers to attach supplementary files for the recipient to view.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating interactive PDF forms that require end-users to upload and attach their own files directly into the document.
- Observed behavior
- Needs to implement a functional button within the PDF that triggers a file attachment dialog using JavaScript annotations.
Ensure you are using Adobe Acrobat Pro to edit form fields and run JavaScript, and inform your users they will need Adobe Reader 11 or later to successfully use the attachment feature.
Use a JavaScript MouseUp Action to Create an Attachment Button
Add a custom JavaScript code to a form button to prompt users to attach a file when clicked.
This method uses the addAnnot method to generate a file attachment annotation dynamically. Because of the security and feature updates in Adobe software, this specific script functionality requires the end-user to open the form in Adobe Reader 11 or a later version.
Open your PDF in Adobe Acrobat, enter 'Prepare Form' mode from the tools pane, and drag a new Button field onto your document.
Right-click the newly created button, select 'Properties', and navigate to the 'Actions' tab.
Choose 'Mouse Up' as the Select Trigger, and select 'Run a JavaScript' from the Select Action dropdown menu.
Click 'Add' and paste the following script into the editor: var annot = this.addAnnot({page: 0, type: "FileAttachment", point: [100, 100], attachIcon: "PushPin", contents: "Attachment"}); annot.cAttachmentPath; Click OK to save and close.

Easily Add and Manage PDF Attachments with WPS Office
While writing custom JavaScript in Acrobat can be complex, WPS Office provides a highly intuitive PDF editor. You can easily insert, view, and manage file attachments directly in your PDFs without needing any coding skills, ensuring smooth document collaboration.
- 1. Open your PDF in WPS Office: Launch WPS Office and open the PDF document where you want to add or manage attachments.
- 2. Navigate to the Comment Tab: Go to the 'Comment' tab on the top ribbon to access the document annotation tools.
- 3. Insert the Attachment: Click on the 'Attachment' tool, click on the desired location on the page, and select the file you want to attach from your computer.

Frequently Asked Questions
Why isn't my PDF file attachment button working for recipients?
The JavaScript file attachment functionality requires Adobe Reader 11 or newer. If recipients are using older versions or third-party PDF viewers (like browser-based PDF readers), the button may not execute the script properly.
Can I change the icon of the file attachment button?
Yes, in the JavaScript code, you can modify the attachIcon property. In the provided script, it is set to 'PushPin', but you can change it to other supported icon names like 'Graph', 'Paperclip', or 'Tag'.
Does adding a file attachment increase the PDF file size?
Yes. When a user attaches a file via the button, the attached file is embedded directly into the PDF document, which will increase the overall file size of the PDF accordingly.
Can I attach multiple files using this JavaScript button?
The provided script adds a single file attachment annotation per click. Users can click the button multiple times to attach multiple files, but each click generates a separate attachment prompt.




