opensagres / xdocreport

XDocReport means XML Document reporting. It's Java API to merge XML document created with MS Office (docx) or OpenOffice (odt), LibreOffice (odt) with a Java model to generate report and convert it if you need to another format (PDF, XHTML...).
https://github.com/opensagres/xdocreport
1.21k stars 372 forks source link

Regarding docx to pdf conversion error #249

Open Parnash opened 6 years ago

Parnash commented 6 years ago

Hi.. When we are trying to convert the docx velocity template to pdf we are facing following error.

An error has occurred while generating the report. Check the template syntax

Error detail:org.apache.poi.xwpf.converter.core.XWPFConverterException: java.lang.ArrayIndexOutOfBoundsException: 3

We are using fr.opensagres.xdocreport.converter.docx.xwpf', version: '1.0.5' jar file. We have also test it with version 2.0.1 but facing the same issue.

'fr.opensagres.xdocreport' jar version is 1.0.6 'fr.opensagres.xdocreport.template' jar version is '2.0.0'

Please find attachment of template in which we are facing the error. DocAuto-Demo.docx

Your Response is valuable for us.

angelozerr commented 6 years ago

To be honnest with you, I have not time to debug your template docx. Are you sure that a simple report generation is working (without conversion).

I suggest really to have a simple docx report and not have some Java logic like:

«#set($sheetTitle="Additional Elements")»«#set($viewName="Default")»«#set($columns={})»«$!{columns.put("DLARef","Matter Referenc»«$!{columns.put("ACO","Assigned Case Owne»«$!{columns.put("ACOEmail","ACO Email Add»«$!{columns.put("Salutation1","Salutation»«$!{columns.put("ForeName1","ForeName(s) »«$!{columns.put("Surname1","Surname #1")}»«$!{columns.put("Salutation2","Salutation»«$!{columns.put("ForeName2","ForeName(s) »«$!{columns.put("Surname2","Surname #2")}»«$!{columns.put("Salutation3","Salutation»«$!{columns.put("ForeName3","ForeName(s) »«$!{columns.put("Surname3","Surname #3")}»«$!{columns.put("Salutation4","Salutation»«$!{columns.put("ForeName4","ForeName(s) »«$!{columns.put("Surname4","Surname #4")}»«$!{columns.put("Property","Property Addr»«$!{columns.put("City","City or Town")}»«$!{columns.put("Postcode","Postcode")}»«$!{columns.put("CompanyName","Name of Co»«$!{columns.put("SolicitorsName","Solicit»«$!{columns.put("SolicitorsAddress","Soli»«$!{columns.put("SolicitorsRef","Solicito»«$!{columns.put("HOPBand","Relevant HOP B»«$!{columns.put("ProposedPayment","Value »«#set($data=$utils.getSheetDocReportDataM»«#set($record=$data.values().iterator().n»

which is awful for a person who have not developed the report and for customer who don't know Java/Freemarker/Velocity advanced syntax.

Parnash commented 6 years ago

Simple report generation is working fine but this template is causing the issue.

angelozerr commented 6 years ago

Simple report generation is working fine but this template is causing the issue.

That's why I suggest you that you simplify your report. I don't understand the use of :

«#set($sheetTitle="Additional Elements")»«#set($viewName="Default")»«#set($columns={})»«$!{columns.put("DLARef","Matter Referenc»«$!{columns.put("ACO","Assigned Case Owne»«$!{columns.put("ACOEmail","ACO Email Add»«$!{columns.put("Salutation1","Salutation»«$!{columns.put("ForeName1","ForeName(s) »«$!{columns.put("Surname1","Surname #1")}»«$!{columns.put("Salutation2","Salutation»«$!{columns.put("ForeName2","ForeName(s) »«$!{columns.put("Surname2","Surname #2")}»«$!{columns.put("Salutation3","Salutation»«$!{columns.put("ForeName3","ForeName(s) »«$!{columns.put("Surname3","Surname #3")}»«$!{columns.put("Salutation4","Salutation»«$!{columns.put("ForeName4","ForeName(s) »«$!{columns.put("Surname4","Surname #4")}»«$!{columns.put("Property","Property Addr»«$!{columns.put("City","City or Town")}»«$!{columns.put("Postcode","Postcode")}»«$!{columns.put("CompanyName","Name of Co»«$!{columns.put("SolicitorsName","Solicit»«$!{columns.put("SolicitorsAddress","Soli»«$!{columns.put("SolicitorsRef","Solicito»«$!{columns.put("HOPBand","Relevant HOP B»«$!{columns.put("ProposedPayment","Value »«#set($data=$utils.getSheetDocReportDataM»«#set($record=$data.values().iterator().n»

To discover the problem, remove some content upon the report can be generated to discover which fields causes problem.

Parnash commented 6 years ago

ohk. Thanks for your Advice and Suggestion.