Expand my Community achievements bar.

How to Render PDF from Adaptive form with data on AEM 6.5

Avatar

Level 3

Hi,

 

We have a requirement to render PDF from Adaptive form on AEM 6.5.

The rendered PDF should have the data from the Adaptive form as well.

 

Currently I am using the below code 

window.guideBridge.getDataXML(
        {
            success: function(result) {
                var formData = new FormData();
                formData.append("dataXml",result.data);
                var url = "servletpath?data=" + result.data + "&path="+path;

to fetch the formdata from the adaptive form. This script is trigged on clicking a button in Adaptive form.

A custom servlet is called from this script, which uses 

formservice.outputservice to render static PDFs along with data.

 

The issue that we are facing is that the application is placed behind SI proxy and the request is then redirected from SI proxy server to AEM load balancer. In this case, the SI prxy server is appending url /abc/def/ to access all the pages on AEM.

As a result, the AF are available on <SIProxydomain>:/abc/def/content/..path of adpative form.

 

This is causing problem when window.guideBridge.getDataXML in the script is trying to access

<SIProxydomain>:/content/..path of adpative form/jcr:content/guideContainer.af.internalsubmit.jsp

as this is internally generated url, I am not able to add /abc/def to this url.

 

Is there any other way to get form data from form fields in an adaptive form and pass it to custom servlet.

Thank you.

 

 

 

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

7 Replies

Avatar

Level 3

Any suggestions will be helpful. Thank you

Avatar

Employee

Hi @SmrithiGo,

You’re running into a issue with proxy and rewriting in front of AEM Forms: internal Adaptive Forms (AF) AJAX calls (such as guideContainer.af.internalsubmit.jsp or similar endpoints) do not automatically include your SI proxy path prefix (/abc/def). This causes problems when the client-side JS tries to interact with endpoints whose URLs no longer directly match the served page URL structure, particularly when a reverse proxy adds such a prefix.

Here’s a summary of the problem and the main ways to solve it for Adaptive Forms on AEM 6.5:


1. Background and Requirements

  • You render an Adaptive Form on a proxied path (e.g., /abc/def/content/...) but internal JS tries to POST/GET to /content/..., missing the /abc/def prefix required by the proxy topology.
  • You want to fetch dataXML from the AF and pass it to a custom servlet to render a PDF with filled data.

2. Why This Happens

  • The URLs for internal AF AJAX endpoints are computed on the server, based on the context path of the AEM instance, and do NOT factor in custom proxy path prefixes.
  • When accessed via a proxy that injects a path segment (/abc/def), the browser “sees” a different base path than the actual internal server-side context, and client JS can’t automatically detect this or prepend the prefix.

3. Solutions and Best Practices

a. Use a Reverse Proxy Rewrite Rule

You can configure your proxy/load balancer to rewrite requests by stripping the /abc/def path before forwarding to AEM, and to correctly handle the reverse for response URLs. This is the most robust solution and aligns with how AEM/AF expects to operate:

Example (Apache):

# Forward /abc/def to AEM, but strip the prefix
ProxyPass /abc/def/ http://aem-int-host:4503/
ProxyPassReverse /abc/def/ http://aem-int-host:4503/

# In dispatcher, add rewrite rule
RewriteRule ^/abc/def/(.*)$ /$1 [PT]

More info:

b. Fix URLs in the Client Side (Not recommended, error-prone)

You could attempt to programmatically detect the path prefix in JavaScript and add /abc/def before making manual XHR/fetch calls, but this approach is brittle:

  • AEM internal AJAX calls (like .af.internalsubmit.jsp) are generated deep in the GuideBridge or submit logic—hard to override.
  • Manually rewriting will fail for internally-generated resource URLs (e.g., dynamic submission, prefill, attachments).

c. Use a Link Transformer or Custom Form Container Adaptation in AEM (Advanced)

Another robust approach is to customize your AEM Adaptive Forms’ form container Sling Model or use a custom Link Transformer so URLs generated for client-side consumption include the correct path prefix:

  • Copy the relevant Sling Model and override methods like getCustomFunctionUrl, getAction, getDataUrl to return URLs with the /abc/def prefix.
  • See GitHub samples and detailed instructions (reference).

d. Server-side Proxy Servlet (if you cannot reconfigure the reverse proxy)

Set up a proxy servlet in AEM that forwards requests to the correct internal endpoints, using the servlet as a fixed entry point that handles path mapping. You direct all AJAX calls to /abc/def/bin/customProxy?target=/content/..., and the servlet resolves it and proxies the call to the real path on AEM.

4. Relevant Docs and Solutions

Thanks

Pranay



Avatar

Level 3

thanks @Pranay_M for the response.

As we dont have access to the proxy server, I believe, we will not be able to go with 

a. Use a Reverse Proxy Rewrite Rule, hence I can try out both of these c. Use a Link Transformer or Custom Form Container Adaptation in AEM (Advanced) and d. Server-side Proxy Servlet (if you cannot reconfigure the reverse proxy).

Will try and let you know. Once again thank you.

 

 

 

Avatar

Moderator

@SmrithiGo , did you try the solution? did it resolve the issue? 

Avatar

Level 3

Hi @Khushwant_Singh No, I am still trying, will keep you posted on the same

Avatar

Level 3

Hi @Pranay_M ,

I tried to customize your AEM Adaptive Forms’ form container Sling Model, but I am stuck as it is not able to resolve this bundle

com.adobe.cq.forms.core.components.models.form,version=[5.4,6) -- Cannot be resolved

 

I have added these dependencies in pom.xml

<!-- https://mvnrepository.com/artifact/com.adobe.aem/core-forms-components-af-core -->
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>core-forms-components-af-core</artifactId>
<version>3.0.40</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.adobe.aem/core-forms-components-core -->
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>core-forms-components-core</artifactId>
<version>3.0.40</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.adobe.aemfd/aem-forms-sdk-api -->
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>aem-forms-sdk-api</artifactId>
<version>2023.06.19.00-230400</version>
</dependency> 

 

but i can see in archetype.properties of the project like this:

includeForms=n
includeFormsenrollment=n
includeFormscommunications=n

 

 

Avatar

Level 3

Hi @Pranay_M , Could you please attach this here. I get certificate error, on accessing the link.

SmrithiGo_0-1762173708583.png

 

See GitHub samples and detailed instructions (reference). here, I am not able to access it.