PDF Editing Issues

How to Dynamically Change an Image in AEM Forms Designer

Kushani NimanthikaKushani Nimanthika Nov 5, 2026 869 views

Question details

The user needs to change the source of an image field dynamically using JavaScript and XML data within AEM Forms Designer 6.5.

How to Dynamically Change an Image in AEM Forms Designer
Product
AEM Forms Designer
Device & OS
not provided
Scenario
Creating an interactive PDF form where an image needs to update automatically based on incoming XML data or user interaction.
Observed behavior
Standard HTML href assignments do not work for image fields in AEM Forms Designer, requiring the correct XFA object model properties and initialization scripts.
Before you start

Ensure that your target images are hosted in a location accessible to your specific PDF rendering environment and are saved in a supported format like JPG or PNG.

Solution 1Recommended

Assign Image Data via JavaScript in Initialization Event

Use the built-in Script Editor to assign the image value dynamically using XFA object properties during the form's initialization.

AEM Forms Designer image fields do not function like standard HTML web images. You cannot simply assign an href attribute.

Instead, you must set the image field's value or data binding directly through its supported content properties.

1
Select the Image Field

Open your form in AEM Forms Designer and click on the target Image Field you wish to update.

2
Open the Script Editor

Navigate to Window > Script Editor to display the scripting console for the selected field.

3
Choose the Initialization Event

From the 'Show' drop-down list at the top of the Script Editor, select the 'initialize' event.

4
Set Language to JavaScript

Change the 'Language' drop-down list to 'JavaScript' to ensure the correct syntax is applied.

5
Write the Assignment Script

Enter the script to set the image value. Use the correct object model reference (e.g., this.rawValue = 'your_image_url_or_data';) to apply the dynamic image data.

Assign Image Data via JavaScript in Initialization Event
Consult Adobe Documentation: Always consult the specific AEM Forms and LiveCycle documentation for the exact object model syntax and supported output formats corresponding to your server version.
Powerful PDF Editor

Easily Edit PDF Images and Forms with WPS Office

While AEM Forms is designed for enterprise-level automated document generation, WPS Office provides a highly intuitive and powerful PDF editor for everyday users to add, modify, and manage images inside PDF forms seamlessly.

  1. 1. Open your PDF: Launch WPS Office and open the PDF document you wish to modify.
  2. 2. Access Edit Mode: Click on the 'Edit' tab located on the top ribbon, then select 'Edit Image'.
  3. 3. Modify the Image: Click directly on any image to replace, resize, or delete it, or choose 'Add Image' to insert a new graphic into your form.
Easily replace and adjust images within standard PDF documentsHighly compatible with standard interactive PDF form layoutsLightweight alternative for quick and efficient PDF editing
QA img-9

Frequently Asked Questions

Can I use standard HTML href attributes to change images in AEM Forms?

No, AEM Forms Designer uses the XFA (XML Forms Architecture) model. Image fields do not use HTML-style href assignments. You must use JavaScript to set the field's raw value or utilize data binding.

Which events are best for running dynamic image scripts?

The 'initialize' or 'calculate' events are generally the most appropriate times to run scripts that dynamically change image sources based on incoming XML data.

Why is my dynamic image not rendering in the final PDF?

This usually happens if the image URL is not accessible to the server rendering the PDF, if the image format is unsupported, or if the PDF output format is set to a static type instead of an interactive or dynamic PDF.

How can I get community support for advanced AEM Forms scripting?

Advanced questions regarding AEM Forms and LiveCycle scripting are best directed to the official Adobe Experience Manager Community forums.