We are using XDP file and XML files to generate the PDF document. We have check boxes in the PDF and javascript included in the XDP file. It is loosing the check box functionality in generated PDF.
Code Snippet
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @ManjulaKo,
I can see that you are using the output service for generating the PDF. I can understand that you have some code which is executing when you click the checkboxes. However, please note that when using the output service to merge the XML with XDP, it is only designed to merge the data into the XDP and generate the PDF with the filled data. Having said that when you pass both the XML and XDP though the output service it only executes the events on the "Initialize event" and the "calculate event". If you have the scripts written on any other events it will not execute the same.
To resolve the problem, please move your code from the specific event to the calculate event and your issue should be resolved.
Thanks
Pranay
Hi @ManjulaKo,
I can see that you are using the output service for generating the PDF. I can understand that you have some code which is executing when you click the checkboxes. However, please note that when using the output service to merge the XML with XDP, it is only designed to merge the data into the XDP and generate the PDF with the filled data. Having said that when you pass both the XML and XDP though the output service it only executes the events on the "Initialize event" and the "calculate event". If you have the scripts written on any other events it will not execute the same.
To resolve the problem, please move your code from the specific event to the calculate event and your issue should be resolved.
Thanks
Pranay
Thanks Pranay. I do have Events in the XDP file. Do we need to move these events code into the XML file?
<event name="event__click" activity="click">
<script contentType="application/x-javascript">
form1.Page1_SP.presence = "visible";
xfa.host.currentPage = 0;
</script>
Do I need to use <event name="event__click" activity="calculate"> instead of click?
Views
Replies
Total Likes
Hi @ManjulaKo,
You don't need to move the events to XML. Instead, as you mentioned, currently, you have the script written on the click event. You will need to move the code logic to calculate the event so that it is triggered at runtime.
In your XML you can simply pass the value for the checkbox as true or false and on the calculate event you just need to add a "if..else" block which checks if the checkbox is selected or not and then perform the specific action.
Thanks
Pranay
Views
Replies
Total Likes
Sure, I will move 'click' events to 'calculate' also, I do have
<event activity="ready" and <event activity="change" events
Which events do I need to replace these two?
Thanks
Manjula
Views
Replies
Total Likes
Hi @ManjulaKo,
If you want your events to execute when you pass the XML, you will need to write that code for the calculate event.
Thanks
Pranay
Views
Replies
Total Likes
Thank you, Pranay. I will try
Views
Replies
Total Likes
It is not working I tried both the calculate and initialize events. Do you have any sample XDP file and XML file to try it out.
Views
Replies
Total Likes
Hi @ManjulaKo,
Sure, I have created a sample test artifact for you to test the usecase. I am attaching a sample XDP and a sample XML file. The form has a single checkbox which is used to show or hide a specific text box depending on the value of the checkbox. In the XML you should see a parameter: <CheckBox1>1</CheckBox1> which you can select to determine the value of the checkbox.
I have also passed the same XDP and XML through the output service and attached the results as well.
Thanks
Pranay
Views
Replies
Total Likes
Thank you, Pranay. I appreciate you sharing the sample files. I was able to set it up in my system and successful generate the PDF using the PDF generation code using AEM. However, the issue is with the generated PDF itself. When I open it, the checkbox is not selectable. I opened a generated PDF in Adobe PDF reader.
Are you seeing the same behavior on your end? or is it correctly working for you?
Thanks
Views
Replies
Total Likes
Hi @ManjulaKo,
The PDF that i attached is the final output PDF, which is generated when you pass the XDP and the XML through the output service code[0] that you are using. Since the resultant output is a flat document you cannot make any selections on the PDF. If you want to see the dynamic version of the PDF, I have attachted the file to the case.
[0] //Flatten PDF
Views
Replies
Total Likes
I want to generate Dynamic version of PDF exactly that you attached.
Views
Replies
Total Likes
The code I shared in the thread is not generating the Dynamic version of PDF,
While the one you shared appears clickable. Do you think the issue is related to the version?
Views
Replies
Total Likes
Hi @ManjulaKo,
The issue is not related to the code. The code that you have shared shows that you are using the Output Service[0] and its method to generate the PDF. When you use the output service, the resultant PDF is a flat PDF. If you want to create a dynamic PDF as a output then you should be using the Forms Service[1] which also takes the input as the XDP and XML but generates Dynamic PDF.
[0]
Views
Replies
Total Likes
Thank you, Pranay. Appreciate your help. Let me try this solution .
Views
Replies
Total Likes
Pranay,
I've updated my code to use the FormsService to generate interactive PDF. When I setRenderAtClient to NO there are no errors in logs
It is generating PDF but not interactive. I am using ECMA script in AEM version 6.5.21 with Java 11. Given that you are able to generate interactive PDF's do you think this issue could be related to AEM and java version I am using?
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies