I'm trying to create a dynamic pdf using Thymeleaf and OpenHtmlToPdf. Each part of the pdf is in a different template. These templates are included or not and the order can be modified. I'm using a java enum that looks like this
public enum FollowupPdfSummaryEnum {
COVER("coverAnchor", "templates/firstPageInclude'.html'", "Couverture", FollowupBlocEnum.COVER_PAGE),
SUMMARY("summaryAnchor", "templates/summaryInclude'.html'", "Sommaire"),
SITUATION_PLAN("situationPlanAnchor", "templates/situationPlanInclude.html", "Plan de situation", FollowupBlocEnum.SITUATION_PLAN),
BUILDING_VISUAL("buildingVisualAnchor", "templates/visualInclude.html", "Visuels", FollowupBlocEnum.BUILDING_VISUAL),
HEALTH_BOOK("healthBookAnchor", "templates/healthBookBatInclude.html", "Carnet de santé", FollowupBlocEnum.HEALTH_BOOK),
IDENTITY_CARD("identityCardAnchor", "templates/identityCardInclude.html", "Fiche d'identité", FollowupBlocEnum.IDENTITY_CARD),
COUNTER_SITUATION_PLAN("counterSituationAnchor", "templates/counterSituationPlanInclude.html", "Plan des compteurs", FollowupBlocEnum.COUNTER_SITUATION_PLAN),
DANGEROUS_MATERIAL("dangerousMaterialAnchor", "templates/dangerousMaterialInclude.html", "Diagnostic Matières Dangereuses", FollowupBlocEnum.DANGEROUS_MATERIAL_DIAGNOSIS),
RECAP_WORK_TODO("workDoneAnchor", "templates/workTodoListInclude.html", "Récapitulatif des travaux à réaliser", FollowupBlocEnum.WORK_DONE_REPORT),
VISIT_REPORT("visitReportAnchor", "templates/visitReportInclude.html", "Rapport de visite", FollowupBlocEnum.VISIT_REPORT),
VISIT_REPORT_OCCUPATION("visitReportOccupationAnchor", "templates/occupationVisitReportInclude.html", "Rapport de visite : Occupations", FollowupBlocEnum.OCCUPATION_VISIT_REPORT),
ANNEXE("annexeAnchor", "templates/annexeInclude.html", "Annexes");
private final String anchor;
private final String pagePath;
private final String title;
private final FollowupBlocEnum block;
private FollowupPdfSummaryEnum(String anchor, String pagePath, String title,
FollowupBlocEnum block) {
this.anchor = anchor;
this.pagePath = pagePath;
this.title = title;
this.block = block;
}
private FollowupPdfSummaryEnum(String anchor, String pagePath, String title) {
this.anchor = anchor;
this.pagePath = pagePath;
this.title = title;
this.block = null;
}
PagePath is the path i'm trying to use to add templates to my pdf. At first I was using something like this to add templates to my pdf
<page-after id="p1"><div th:replace="templates/firstPageInclude.html"></div></page-after>
Then I replace it with something more dynamic
<th:block th:each="summaryItem : *{summary}">
<page-after id="${summaryItem.anchor}"><div th:replace= "${summaryItem.pagePath}"></div></page-after>
</th:block>
Summary is a list of FollowupPdfSummaryEnum. Looks like it can't find the string path so it can't find the template. If you have any idea, i'll take it thanks :)
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating OGNL expression: "summaryItem.pagePath"