This module provides a task to create a PDF from templates and form Response data.
/!\ Prerequisite : the libawt_xawt.so library should be provided by the JDK. /!\
Templates
Templates should be created from the back office feature. Templates use HTML.
The "displayEntry" macro is used to display form response data in the HTML template. This macro takes a parameter “q” which corresponds to the value of the answer contained in “position_X”.
Examples :
<#@displayEntry q=position_7/>
[#@displayEntry q=position_7/]
Customizing the display of question types (entrytype)
The Form plugin offers different types of questions: date, text, image, file etc. To adapt the display of answers according to their type (Entrytype), the module-workflow-formstopdf uses Freemarker macros. In the source code of the module, there is a macro whose role is to call the macro that corresponds to the Entrytype of the question. This "displayEntry" can be overridden , it is located here : .../webapp/WEB-INF/templates/admin/plugins/workflow/modules/formspdf/display_entries/displayEntry.ftl
<#macro displayEntry q>
<#if q??>
<#assign entry=q.question.entry >
<#assign list_responses=q.getEntryResponse() >
<#if entry.entryType.beanName == "forms.entryTypeArray">
<@displayEntryTypeArray entry=entry list_responses=list_responses />
<#elseif entry.entryType.beanName == "forms.entryTypeAutomaticFileReading">
<@displayEntryTypeAutoFileReading entry=entry list_responses=list_responses />
...
The entry macros can be overriden, like
<#macro displayEntryTypeText entry list_responses> <!-- override with custom content --> </#macro>
Choice of Freemarker Macros Syntax
To use macros in RichTextEditor, and avoid character escaping from the editor, you must modify the Freemarker syntax mode, by selecting the "brackets" mode.
[#ftl] will be added in the beginning of the template, and Freemarker will recognize macros use such as :
[@myMacro arg1= arg1/]”.