PDF Editing Issues

How to Add File Attachments and Display File Names in LiveCycle Designer

Emma BrownEmma Brown Oct 28, 2026 869 views

Question details

The user wants to configure a PDF form to accept file attachments and dynamically display the attached file's exact name next to the attachment button.

How to Add File Attachments and Display File Names in LiveCycle Designer
Product
Adobe LiveCycle Designer
Device & OS
not provided
Scenario
Designing an interactive PDF form where users need to upload supporting documents and immediately see the name of the file they attached for verification.
Observed behavior
Requires a custom scripting solution to bind the attachment upload action to a specific text field that updates with the file name.
Before you start

Ensure your LiveCycle Designer form is configured to save as a Dynamic XML Form rather than a Static PDF, as static forms often restrict real-time updates to text fields via scripts.

Solution 1Recommended

Use JavaScript to Bind the Attachment Action to a Text Field

Implement a custom JavaScript snippet on the button's click event to invoke the PDF attachment dialog and extract the file name to a target text field.

Because LiveCycle Designer uses the XFA framework, handling attachments requires bridging the form design with Acrobat's JavaScript Object Model. The script will prompt the user to select a file, attach it to the PDF data object, and then retrieve the file name property to populate your display field.

1
Create the Layout Objects

Add a 'Button' object to act as the attachment trigger. Next to it, insert a 'Text Field' object and name it 'FileNameDisplay' in the Hierarchy palette. Set the Text Field's access to 'Read Only' so users cannot manually type over the file name.

2
Open the Script Editor

Select the Button object, go to the Window menu, and click on 'Script Editor'. Set the language dropdown to 'JavaScript', the 'Show' dropdown to the 'click' event, and ensure the 'Run At' setting is set to 'Client'.

3
Insert the Attachment Script

Input a script utilizing the 'event.target.importDataObject' method. For example: 'var myDoc = event.target; myDoc.importDataObject("UserAttachment");'.

4
Extract and Display the File Name

Add logic directly below to retrieve the name of the newly attached data object and assign it to the text field's raw value: 'var myData = myDoc.getDataObject("UserAttachment"); if (myData) { FileNameDisplay.rawValue = myData.name; }'.

Use JavaScript to Bind the Attachment Action to a Text Field
Client Compatibility: These dynamic XFA scripts rely heavily on the Adobe Acrobat JavaScript API. End-users must open the form in a fully compatible PDF viewer (like Adobe Acrobat or Reader) for the attachment and renaming functions to execute properly.

Easily Add Attachments to PDFs with WPS Office

If writing complex JavaScript in LiveCycle Designer is too time-consuming or overkill for your needs, you can use WPS Office to directly attach files to any standard PDF document. WPS PDF provides a highly intuitive interface to embed files, add comments, and modify PDFs without any coding.

  1. 1. Open your PDF Document: Launch WPS Office and open the PDF file where you need to append supplementary files.
  2. 2. Access the Comment Tools: Navigate to the 'Comment' tab on the top ribbon to access the advanced annotation tools.
  3. 3. Insert the Attachment: Click the 'Attachment' button, then click on the specific area of the PDF page where you want the attachment icon to be placed.
  4. 4. Select the File: Choose the file you wish to attach from your computer's local storage and customize the icon's color and appearance.
No JavaScript or coding required to add attachmentsHighly compatible with standard Microsoft Office and Adobe PDF formatsFree, lightweight, and fast PDF editing toolsFamiliar user interface for a seamless workflow transition
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't the file name updating when I click the attachment button in LiveCycle?

This usually happens if the script is referencing the wrong text field name, or if the PDF is saved as a Static PDF instead of a Dynamic XML PDF. Double-check your object naming in the Hierarchy palette and ensure the script correctly points to the 'rawValue' of the text field.

Can I use FormCalc instead of JavaScript for attachments?

FormCalc has limited support for the advanced Acrobat Object Model required to handle native file attachments and data objects. JavaScript is the universally recommended language for executing attachment scripts in LiveCycle Designer.

Will forms created with dynamic LiveCycle scripts work in all PDF viewers?

No. Forms utilizing complex XFA (XML Forms Architecture) scripts, such as dynamic attachment handling, typically require Adobe Acrobat or Adobe Reader. Many third-party browsers and basic PDF viewers do not fully support XFA JavaScript.

How do I remove an attachment using a button script?

You can create a 'Remove Attachment' button and bind a JavaScript event using the 'event.target.removeDataObject("AttachmentName")' method to delete the specific attachment from the PDF, followed by clearing the text field's rawValue.