How to Dynamically Change an Image in AEM Forms Designer
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.

- 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.
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.
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.
Open your form in AEM Forms Designer and click on the target Image Field you wish to update.
Navigate to Window > Script Editor to display the scripting console for the selected field.
From the 'Show' drop-down list at the top of the Script Editor, select the 'initialize' event.
Change the 'Language' drop-down list to 'JavaScript' to ensure the correct syntax is applied.
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.

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. Open your PDF: Launch WPS Office and open the PDF document you wish to modify.
- 2. Access Edit Mode: Click on the 'Edit' tab located on the top ribbon, then select 'Edit Image'.
- 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.

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.




