I'm working on a project where I need to generate a PDF document from an HTML template, specifically to display the results of a Likert scale. The data for the Likert scale is provided in a JSON payload, but I'm encountering issues with correctly populating this data into the PDF. I can populate the list in its entirety but would like to populate each item in it's appropriate cell.
<div class="header">Emergency Duties Feedback</div>
<p>{{EmergencyDutiesFeedback}}</p>
<p>{{EmergencyDutiesLikert}}</p>
<p>{{EmergencyDutiesLikert[0]}}</p>
<table>
<!-- Emergency Duties Criteria -->
<tr><td>Response Towards Training and Emergency Activities</td><td>{{EmergencyDutiesLikert.[0]}}</td></tr>
<tr><td>Ability to Learn, Retain, and Apply Information</td><td>{{EmergencyDutiesLikert.[1]}}</td></tr>
<tr><td>Effort to Improve</td><td>{{EmergencyDutiesLikert.[2]}}</td></tr>
<!-- ... -->
</table>
The issue is that the resulting PDF does not display the Likert scale evaluations as expected. Here's an example of the output I'm getting (screenshot attached):
Does anyone have insights on what might be going wrong or what I'm missing in this process? Any help or suggestions would be greatly appreciated!
I reproduced the issue and I'm going to discuss with my team if we can address the array elements this way {{EmergencyDutiesLikert[0]}} or {{EmergencyDutiesLikert.[0]}}. I'll keep you posted about the results.
Thank you, Petr. I also recommend changing the current JSON payload for Likerts so that each item in the array includes both the question and the response.
"EmergencyDutiesLikert": [
{
"Question": "Response Towards Training and Emergency Activities",
"Response": "Above Standards"
},
{
"Question": "Ability to Learn, Retain, and Apply Information",
"Response": "Meets Standards"
},
...
]
How to Call it in the HTML Template:
With the proposed JSON structure, the HTML template can be simplified to iterate through each object in the Likert arrays, displaying both the question and the response. Here's an example of how it can be implemented: