PDF Editing Issues

How to Add a File Attachment Button to a PDF Form in Adobe Acrobat

Steven ParkerSteven Parker Oct 28, 2026 869 views

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.

How to Add a File Attachment Button to an Acrobat PDF Form
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.
Before you start

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.

Solution 1Recommended

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.

1
Add a Button to the PDF Form

Open your PDF in Adobe Acrobat, enter 'Prepare Form' mode from the tools pane, and drag a new Button field onto your document.

2
Access Button Properties

Right-click the newly created button, select 'Properties', and navigate to the 'Actions' tab.

3
Set the Action Trigger

Choose 'Mouse Up' as the Select Trigger, and select 'Run a JavaScript' from the Select Action dropdown menu.

4
Input the JavaScript Code

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.

Use a JavaScript MouseUp Action to Create an Attachment Button
Compatibility Requirement: For this button to work correctly, recipients must fill out the form using Adobe Reader 11 or newer. Earlier versions or non-Adobe PDF viewers may fail to process the attachment script.
Easy PDF Attachment Management

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. 1. Open your PDF in WPS Office: Launch WPS Office and open the PDF document where you want to add or manage attachments.
  2. 2. Navigate to the Comment Tab: Go to the 'Comment' tab on the top ribbon to access the document annotation tools.
  3. 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.
Insert file attachments into PDFs directly through a visual interface without writing JavaScript.Highly compatible with standard PDF formats and forms created in Adobe Acrobat.Free and lightweight PDF viewing and editing tools for Windows, Mac, and mobile devices.
microsoft office alternative - wps office

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.