Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 359 by
alexonho...@gmail.com: NullPointerException when
converting a sample docx to pdf file
http://code.google.com/p/xdocreport/issues/detail?id=359
What steps will reproduce the problem?
1. Code:
public class Docx2Pdf {
public static void main(String[] args) throws IOException {
long start = System.currentTimeMillis();
InputStream is = new FileInputStream(new
File("/Users/chengliang/docs/unmarshallFromTemplateExample.docx"));
XWPFDocument document = new XWPFDocument(is);
PdfOptions options = PdfOptions.create();
OutputStream out = new FileOutputStream(new
File("/Users/chengliang/out/test.pdf"));
PdfConverter.getInstance().convert(document, out, options);
System.err.println("Generate pdf with " +
(System.currentTimeMillis() - start) + "ms");
}
}
2. I was using
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>fr.opensagres.xdocreport.document.docx</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>fr.opensagres.xdocreport.template.freemarker</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>fr.opensagres.xdocreport.converter.docx.xwpf</artifactId>
<version>1.0.3</version>
</dependency>
What is the expected output? What do you see instead?
Expecting a pdf file to be generated. I saw
Exception in thread "main"
org.apache.poi.xwpf.converter.core.XWPFConverterException:
java.lang.NullPointerException
at
org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:59)
at
org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:37)
at
org.apache.poi.xwpf.converter.core.AbstractXWPFConverter.convert(AbstractXWPFConverter.java:45)
at com.namedropper.integrationtest.Docx2Pdf.main(Docx2Pdf.java:23)
Caused by: java.lang.NullPointerException
at
org.apache.poi.xwpf.converter.core.MasterPageManager.visitHeadersFooters(MasterPageManager.java:198)
at
org.apache.poi.xwpf.converter.core.MasterPageManager.addSection(MasterPageManager.java:178)
at
org.apache.poi.xwpf.converter.core.MasterPageManager.compute(MasterPageManager.java:125)
at
org.apache.poi.xwpf.converter.core.MasterPageManager.initialize(MasterPageManager.java:95)
at
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.visitBodyElements(XWPFDocumentVisitor.java:226)
at
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.start(XWPFDocumentVisitor.java:193)
at
org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:55)
... 3 more
What version of the product are you using? On what operating system?
I am using eclipse/JDK 1.7 on Mac os Mavericks
Please provide any additional information below.
Attachments:
unmarshallFromTemplateExample.docx 3.1 KB
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings