Can we capture events from Adaptive form for a button and use that while rendering static PDF from AF | Community
Skip to main content
Level 4
May 29, 2026
Solved

Can we capture events from Adaptive form for a button and use that while rendering static PDF from AF

  • May 29, 2026
  • 4 replies
  • 94 views

hi,

I am facing an issue while rendering PDF from Adaptive forms (build using foundation component) on AEM 6.5.24. The Adaptive form is created using XDP template and the fields are binded too.

The issue is that the form has a button, and on click runs a script which enables a subform.

The event works fine on Adaptive form too. When the button is click the adaptive fragment (which is the subform in xdp) is visible and the other fields are hidden. The problem is when we render PDF from Adaptive form. The then subform is still hidden. 

I believe the since it is an UI event on Adaptive, the XDP is not aware of it and it still hides the subform.

Is there any way to make subform visible using a button click on Adaptive form?

Thank you.

Best answer by Pranay_M

Hi ​@SmrithiGo,

Thank you for reaching out regarding the subform visibility issue when rendering PDFs from your Adaptive Form on AEM 6.5.24.

I have investigated the behaviour you described and would like to share my findings along with recommended solutions.

Root Cause:
Base on your form design, the visibility change is triggered by the button click on your Adaptive Form whi h is handled at the UI layer (JavaScript/client-side event). When a PDF is rendered, the XDP template is processed independently and does not replay UI-layer events — it only has access to the submitted data model. As a result, the subform remains in its default hidden state in the rendered PDF.

This is a very common scenario which we have seen with multiple customers working with XFA based forms and Adaptive Forms as well.

Recommended Solution:
The most reliable fix is to bind the subform's visibility to a data field value, so the state is carried through to the PDF renderer:

1. Add a hidden field (e.g., showSubform) of type text/number  to your data model with a default value of 0.
2. In the button's click script on the Adaptive Form, set this field's value to 1 alongside your existing visibility logic.
3. In the XDP template, add the following script to the subform's calculate event:

   if (xfa.resolveNode("$.showSubform").rawValue == "1") {
       this.presence = "visible";
   } else {
       this.presence = "hidden";
   }

This ensures that when the PDF is rendered, the XDP reads the data value and reflects the correct visibility state.

Additional Checks
- Please verify that the prefill/submitted data XML being passed to the PDF renderer includes the updated field values.
- Ensure all relevant AEM 6.5 Forms Service Packs and hotfixes are applied, as some dynamic subform rendering issues have been addressed in recent updates. You can check the bundle version at: system/console/bundles (com.adobe.aemfd.adobe-aemfd-af-core).

Please feel free to reach out if you need assistance with the XDP script syntax, data binding configuration, or any further clarification. We are happy to assist.

Thanks

Pranay

4 replies

Pranay_MAdobe EmployeeAccepted solution
Adobe Employee
June 2, 2026

Hi ​@SmrithiGo,

Thank you for reaching out regarding the subform visibility issue when rendering PDFs from your Adaptive Form on AEM 6.5.24.

I have investigated the behaviour you described and would like to share my findings along with recommended solutions.

Root Cause:
Base on your form design, the visibility change is triggered by the button click on your Adaptive Form whi h is handled at the UI layer (JavaScript/client-side event). When a PDF is rendered, the XDP template is processed independently and does not replay UI-layer events — it only has access to the submitted data model. As a result, the subform remains in its default hidden state in the rendered PDF.

This is a very common scenario which we have seen with multiple customers working with XFA based forms and Adaptive Forms as well.

Recommended Solution:
The most reliable fix is to bind the subform's visibility to a data field value, so the state is carried through to the PDF renderer:

1. Add a hidden field (e.g., showSubform) of type text/number  to your data model with a default value of 0.
2. In the button's click script on the Adaptive Form, set this field's value to 1 alongside your existing visibility logic.
3. In the XDP template, add the following script to the subform's calculate event:

   if (xfa.resolveNode("$.showSubform").rawValue == "1") {
       this.presence = "visible";
   } else {
       this.presence = "hidden";
   }

This ensures that when the PDF is rendered, the XDP reads the data value and reflects the correct visibility state.

Additional Checks
- Please verify that the prefill/submitted data XML being passed to the PDF renderer includes the updated field values.
- Ensure all relevant AEM 6.5 Forms Service Packs and hotfixes are applied, as some dynamic subform rendering issues have been addressed in recent updates. You can check the bundle version at: system/console/bundles (com.adobe.aemfd.adobe-aemfd-af-core).

Please feel free to reach out if you need assistance with the XDP script syntax, data binding configuration, or any further clarification. We are happy to assist.

Thanks

Pranay

SmrithiGoAuthor
Level 4
June 2, 2026

Thanks ​@Pranay_M  for your response.

I will try this out and keep you posted. 

I was trying to do the same, but still not working, just wanted to know would this work for use case, where the OK button is on one subform and fields which needs to be rendered on PDF are on separate subform.

SmrithiGoAuthor
Level 4
June 3, 2026

HI ​@Pranay_M , I tired out the following on an XDP file with OK button.

The requirement is when user clicks on OK button, a subform is made visible (which is basically another fragment associated). The user fills the fields in the fragment and on click on download, AEM forms API outputService.generatePDFOutput(xdpDocument, submittedData, pdfOutputOptions), we generate the static PDF from Adaptive form.

On adding the this script to Ok button :

var node = xfa.resolveNode("form1.formState.count");
node.rawValue = 0;

// Force form to refresh calculations + layout
xfa.form.recalculate(true);
xfa.layout.relayout();
 

as form1 is the parent node for formstate as shown below. I have added a hidden numeric field, and the value is set by default as 1,  when OK button is clicked, it changes to =, which is working fine on Adaptive form as well.

this is the structure of the form:

!--scriptorstartfragment-->

form1

││

├── subform

│   └── (path to Subform)

├── subformwithbutton

│  │─ OK   ← (OK button here)

├── formState

│   └── count


!--scriptorendfragment-->

On the subform , calculate event , this is added:

if (xfa.resolveNode("form1.formState.count").rawValue == 0) {
    this.presence = "visible";
} else {
    this.presence = "hidden";
}

When the static PDF is generated using outputService.generatePDFOutput(xdpDocument, submittedData, pdfOutputOptions), I dont see the subform fields on them. 

Adobe Employee
June 3, 2026

Hi ​@SmrithiGo,

When you are generating the static PDF using the outputService. generatePDFOutput(xdpDocument, submittedData, pdfOutputOptions), are you also passing the value of the variable which is responsible for controlling the visibliity logic?

Thanks
Pranay

SmrithiGoAuthor
Level 4
June 4, 2026

Yes ​@Pranay_M , that will be there as part of submittedData which I am fetching from formData using guideBridge API. Is that sufficient or should we have any logic in place within BE to handle it 

SmrithiGoAuthor
Level 4
June 5, 2026

 

Hi ​@Pranay_M ,

This is the XML data that is passed on :

<formState><count>0</count></formState>

This  window.guideBridge.getDataXML gets the formData from Adaptive form and then passes to outputService.generatePDFOutput(xdpDocument, submittedData, pdfOutputOptions)

SmrithiGoAuthor
Level 4
June 8, 2026

Just an update, by adding an hidden numeric field which changes between 1 to 0 based on user click and having scripts in calculate event based on this value, finally worked. Thank you ​@Pranay_M