How to Render PDF from Adaptive form with data on AEM 6.5 | Community
Skip to main content
Level 4
October 22, 2025

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

  • October 22, 2025
  • 2 replies
  • 454 views

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.

 

 

 

 

 

2 replies

SmrithiGoAuthor
Level 4
October 28, 2025

Any suggestions will be helpful. Thank you

Adobe Employee
October 28, 2025

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



SmrithiGoAuthor
Level 4
February 12, 2026

Hi ​@Pranay_M , I am trying out reverse proxy steps that you have mentioned. Meanwhile also this approach: . Server-side Proxy Servlet (if you cannot reconfigure the reverse proxy). 
 

In this approach how do I invoke my server side proxy servlet from adaptive form. Could you please elaborate on what does this servlet do. 

Any time this call happens windows.guideBridge.getDataXML(), it fails:

window.guideBridge.getDataXML(
{
success: function(result) {
var formData = new FormData();
formData.append("dataXml",result.data);
var protocol = window.location.protocol;
var domain = window.location.host;
var initialUrl = protocol + "//" + domain;
var path = window.location.pathname.replace(/\.html$/, '');
var url = "/abc/def/bin/pdfgenerator?data=" + result.data + "&path="+path;
var finalUrl = initialUrl+url;
window.open(finalUrl,"_blank");

},
error:function(guideResultObject) {console.log("got error"); },
guideState : null,
boundData : true});

Can you please let me know when the server side proxy servlet can be called and how will it redirect to correct internal.submit.jsp path

SmrithiGoAuthor
Level 4
February 12, 2026

@Pranay_M  ​@Khushwant_Singh  Can you please let me know how does AEM Proxy servlet work in this case:

Adaptive form is loading here https://SI:Proxydomain/abc/def/content/forms/af/abc-sample-smrithi/abc.html

I have created a custom button, on click on the button, a custom clientlib is invoked and 

renderPDF function is called.

window.guideBridge.getDataXML(
{
success: function(result) {
var formData = new FormData();
formData.append("dataXml",result.data);
var protocol = window.location.protocol;
var domain = window.location.host;
var initialUrl = protocol + "//" + domain;
var path = window.location.pathname.replace(/\.html$/, '');
var url = "/abc/def/bin/pdfgenerator?data=" + result.data + "&path="+path;
var finalUrl = initialUrl+url;
window.open(finalUrl,"_blank");

},
error:function(guideResultObject) {console.log("got error"); },
guideState : null,
boundData : true});

this is failing as below:

csrf.min.js:7 
 
 POST https://SIProxydomain/content/forms/af/abc-sample-smrithi/abc/jcr:content/guideContainer.af.internalsubmit.jsp 404 (Not Found)
XMLHttpRequest.send    @    csrf.min.js:7
send    @    en.min.js:2
ajax    @    en.min.js:2
_doInternalSubmit    @    guideRuntimeWithXFA.min.js:35308
success    @    guideRuntimeWithXFA.min.js:35327
getGuideState    @    guideRuntimeWithXFA.min.js:34552
_submitInternal    @    guideRuntimeWithXFA.min.js:35323
getData    @    guideRuntimeWithXFA.min.js:33544
getDataXML    @    guideRuntimeWithXFA.min.js:33485
getPdf    @    clientlib-adaptive-forms.min.js:127
eval    @    VM939:1
eval    @    VM897:6
_expressionHandler    @    guideRuntimeWithXFA.min.js:45058
executeExpression    @    guideRuntimeWithXFA.min.js:44991
handleClick    @    guideRuntimeWithXFA.min.js:40264
i    @    en.min.js:2
dispatch    @    en.min.js:2
v.handle    @    en.min.js:2
trigger    @    en.min.js:2
(anonymous)    @    en.min.js:2
each    @    en.min.js:2
each    @    en.min.js:2
trigger    @    en.min.js:2
_trigger    @    en.min.js:708
(anonymous)    @    guideRuntimeWithXFA.min.js:6857
dispatch    @    en.min.js:2
v.handle    @    en.min.js:2

 

As you can see, internal submit POST call (https://SIProxydomain/content/forms/af/abc-sample-smrithi/abc/jcr:content/guideContainer.af.internalsubmit.jsp 404 (Not Found)) is not adding /abc/def/ in the URL. I believe this is causing the failure.