Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

AEM 6.5 HTML5 form -printing visible pages

Avatar

Level 5

Hi,

I have a XDP form that has 3 pages. When this form is rendered as HTML5, it is set to have only the main first page visible and the remaining 2 pages as hidden (exclude from layout). When a check box is clicked in the main page then the remaining 2 pages become visible and allow the user to enter the data. This works until the data is filled in. 

But when trying to print/save as static PDF, only the main/first page is printed, but not the reset of the pages. I tried the following JavaScript code but the +print is not having any effect.

this.resolveNode("form1.page2").presence = "visible";
this.resolveNode("form1.page2").relevant = "+print";

Any suggestion on how to fix this?

Thanks,

Leena

14 Replies

Avatar

Community Advisor

Can you please share your form to look into?

Avatar

Level 5

Hi Vijay,

Is there an email address to which I can send it to?

Thanks,

Leena

Avatar

Level 5

Vijay,

My apologies, since it is business document I can't sent it. I will try to fix it myself.

Thanks,

Leena

Avatar

Level 5

Hi Vijay,

I created a sample form that resembles the issue. It is saved as dynamic PDF so it can be attached to this post. It needs to be saved back into XDP form to test it. On checking the 'G M' checkbox in 'Main Page 1', the second page needs to be visible as the next separate page. Currently, on checking the "GM' checkbox the second page is blank and appears as part of the main page. On clicking the 'Submit' button both the pages need to be saved as static PDF and sent to the client browser.

The AEM uses custom code to render this xdp form to HTML5 form in the browser.  The code uses outputService.generatePDFOutput(). This works for all XDP forms except for this forms where the second page is hidden, and it needs to be made visible on clicking on a checkbox.

In the AEM Designer 6.5 the XDP form appears to work in the 'Preview PDF' tab, but in the 'Preview HTML' tab is shows as loading, but never displays the form.

Any help on this would be great.

Thanks,

Leena

 

Avatar

Community Advisor

Once the form is rendered with outputService.generatePDFOutput() service,  the dynamic behavior of the forms will not work, i.e. button, checkbox click, etc.

Avatar

Level 5

Hi Vijay,

In the AEM CRX, the sling:resourceType uses /content/profiles/ to render the XDP as HTML5 form. In the URL all the buttons, checkboxes etc., and events work in the form. Only after the form is filled in and submitted is the data transferred as XML to the AEM server where the code uses the data, form template and outputService.generatePDFOutput() service to generate the static PDF and sends it to the browser. 

I have attached PrintIssue_v2.pdf to this post. I am able to view the XDP version of this PrintIssue_v2.pdf in the Designer's 'Preview HTML' tab. On clicking the 'G M' checkbox in the main page, the second page is displayed as a separate page. After uploading the XDP template in the AEM server and viewing it from the URL, the same form displays both the pages when clicking the checkbox. But looks like the second page is not in a separate content Area since it appears to be continuing from the main page. On clicking the submit button only the first/main page is saved as static PDF, it does not include the second page in the static PDF.

The only issue now is that the second page is not saved/printed/visible in the generated static PDF.

Thanks,

Leena

 

Avatar

Level 5

Hi,

I redesigned the XDP form by moving the contents from the second bode page to a second master page. Created flowed second page with positioned sub form. Both the second body page and subform are in the content area of the second master page. The form is working as expected when the check box is clicked to display the second page. But now even when the second page is hidden when the checkbox is unchecked, it gets printed/saved as static PDF. This may be because the contents are in the second master page. How do I hide the contents in the master page from being printed/saved as static PDF? 

I tried both "invisible' and "hidden" values but the second page still gets printed/saved as static PDF.

this.resolveNode("form.#pageSet[0].Page2").presence = "invisible";

xfa.resolveNode("form.#pageSet[0].Page2").presence = "hidden"; 

The second page should not print when the checkbox is unchecked.

Any suggestions?

Avatar

Level 5

Is there a solution to hide both master page and body page from being saved as static PDF?

Avatar

Level 5

Hi Kosta_Prokopiu1,

Any suggestion on how to resolve this?

Thanks,

Leena

Avatar

Level 5

Hi,

In the Designer when trying to view the XDP form in "Preview HTML' tab the following error is seen in the debug.log. It is trying to load but the form is not displayed in the preview html tab. 

[0109/092049:INFO:CONSOLE(0)] "Uncaught ReferenceError: highlightFields is not defined," source: http://localhost:4551/content/profiles/courtyardForm.html(62)
[0109/092051:INFO:CONSOLE(0)] "Uncaught TypeError: Object editPattern1,editPattern2,editPattern3,editPattern4,editPattern5,editPattern6 has no method 'find'," source: http://localhost:4551/etc.clientlibs/fd/xfaforms/clientlibs/profile.js(42311)
[0109/092051:INFO:CONSOLE(0)] "Uncaught TypeError: Cannot call method '_formDomRoot' of null," source: http://localhost:4551/etc.clientlibs/fd/xfaforms/clientlibs/profile.js(62192)

Any suggest on how this can be fixed?

Thanks,

Leena

Avatar

Level 5

Hi,

Here is a simple new sample of the issue. Save the attached V2_Test25.pdf as XDP template using AEM Designer 6.5. Upload this XDP form to AEM 6.5 server that has outputService.generatePDFOutput() service and AEM code to render it as HTML5 form, 

In the form, the body page2 is set to 'Hidden (Exclude from Layout) , and when checkbox is clicked, the body page2 becomes visible and flows/continues from body page 1, instead of appearing as a separate page even when a separate master page is used. On changing the BodyPag2 property to visible then this page appears correctly as a separate page when the check box is checked.

When the checkbox is unchecked and the BodyPage2 is hidden and not visible in the HTML5 form when viewed from the URL, it still gets printed along with BodyPage1 when HTTP submit button is clicked. On clicking the HTTP submit button, the data is sent to the AEM server as XML. The outputService.generatePDFOutput() service is used to generate the static PDF and it is sent to the client. 

What needs to be changed to get this form to work? Or is this a bug/limitation with AEM forms? 

Thanks,

Leena

Avatar

Level 3

I opened your xfa pdf and previewed it.

When I checked the checkbox the Javascript Debugger threw the following message:

GeneralError: Operation failed.
XFAObject.resolveNode:3:XFA:form1[0]:BodyPage1[0]:CheckBox1[0]:change
Malformed SOM expression: .form1.BodyPage2

 

The code on the change event was written:

if( this.resolveNode("form1.BodyPage1.CheckBox1").rawValue = "0"){
this.resolveNode(".form1.BodyPage2").presence = "hidden";
}
if( this.resolveNode("form1.BodyPage1.CheckBox1").rawValue = "1"){
this.resolveNode(".form1.BodyPage2").presence = "visible";
}

 

This issue with this code is the (".form1.BodyPage2")  There is no need for a "." before form1. If you fix that then the PDF seems to work as you want it to.

There is also code on buttons that are on the Master Page. I am thinking, that from experience,  you probably should resolveNode those statements. Others on this list might have other thoughts.

Avatar

Level 5

Hi Koolforms,

Thanks for the feedback. I am trying to make this work as an HTML form. I removed the period and added the resolveNode in the master page. Please see the attached V3_Test26.pdf. This needs to be saved as XDP form and can view it in AEM Designer 6.5. It needs to be uploaded in AEM Sever that supports the rendering of the XDP form as HTML5 form in the browser. In the Designer, can use the View | Tools | Server Options to configure the server URL and port number. Can view this form in the Designer's 'Preview PDF' and 'Preview HTML' tab. 

In the 'Preview HTML' tab when the checkbox is clicked, the BodyPage2 is visible, but it appears as continuing/flowing from the BodyPage1, and not as a separate page. The checkbox is not unchecking after the BodyPage2 is made visible. 

What can be done to fix it? After this is fixed, 'HTTP Submit Button' needs to be added to this form and this form needs to be uploaded to the AEM server. On rendering this form as HTML form in the browser from the AEM server, on clicking this 'HTTP Submit Button' the form needs to be saved as static pdf. If the checkbox is 'On' then both pages need to be print. If the checkbox is unchecked then only the BodyPage1 needs to be printed.

Are there any other code change that needs to be done?

Thanks,

Leena