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.23k stars 374 forks source link

org.apache.poi.xwpf.converter.core.XWPFConverterException: java.lang.NullPointerException while converting docx with tables to pdf #364

Open RishabhSharma2906 opened 5 years ago

RishabhSharma2906 commented 5 years ago

org.apache.poi.xwpf.converter.core.XWPFConverterException: java.lang.NullPointerException at org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:70) at org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:38) at org.apache.poi.xwpf.converter.core.AbstractXWPFConverter.convert(AbstractXWPFConverter.java:45) at com.teradata.tdm.pma.service.PDFReport.generateCurrentPdf(PDFReport.java:405) at com.teradata.tdm.pma.service.PDFReport.generatePDF(PDFReport.java:381) at com.teradata.tdm.pma.service.PDFReport.main(PDFReport.java:116) Caused by: java.lang.NullPointerException at org.apache.poi.xwpf.converter.core.MasterPageManager.visitHeadersFooters(MasterPageManager.java:200) at org.apache.poi.xwpf.converter.core.MasterPageManager.addSection(MasterPageManager.java:180) at org.apache.poi.xwpf.converter.core.MasterPageManager.compute(MasterPageManager.java:127) at org.apache.poi.xwpf.converter.core.MasterPageManager.initialize(MasterPageManager.java:90) at org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.visitBodyElements(XWPFDocumentVisitor.java:232) at org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.start(XWPFDocumentVisitor.java:199) at org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:56) ... 5 more

RishabhSharma2906 commented 5 years ago

Hi, I am trying to convert a document in .docx containing some tables and text to .pdf format but I am getting this issue. Can anyone suggest what mistake I am making?

Below are the content of the build.gradle corresponding to generation of .docx file and converting it to pdf:- compile group: 'org.apache.poi', name: 'poi-ooxml', version: '3.9' compile group: 'org.apache.poi', name: 'poi', version: '3.9' compile group: 'fr.opensagres.xdocreport', name: 'org.apache.poi.xwpf.converter.pdf' , version: '1.0.6'

fochoac commented 5 years ago

Hi, I generate word report to pdf with tables. Please check my pom.xml and test examples. Pom file: https://github.com/fochoac/report4j/blob/master/pom.xml.

Regards.