title: POI - Unexpected end of file after null
body: <p>I've a problem with converting docx file created with poi to pdf.
  I create file with next code (just empty file, but I've tried with filled with text/images):</p>
  
  <pre><code>   private static void createEmpty() throws IOException{
           XWPFDocument doc = new XWPFDocument();
           FileOutputStream out = new FileOutputStream("empty.docx");
           doc.write(out);
           out.close();
           doc.close();
     }
  </code></pre>
  
  <p>The file I ge I could open with Word 2010 and it looks fine, however when I try to convert it to pdf with POI pdfConverter I get an error:</p>
  
  <pre><code>org.apache.poi.xwpf.converter.core.XWPFConverterException: org.apache.xmlbeans.XmlException: error: Unexpected end of file after null
     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 sbt.oot.metrics.pdf.DocxToPdfConverter.create(DocxToPdfConverter.java:44)
     at sbt.oot.metrics.pdf.DocxToPdfConverter.main(DocxToPdfConverter.java:23)
  Caused by: org.apache.xmlbeans.XmlException: error: Unexpected end of file after null
     at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3471)
     at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1270)
     at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1257)
     at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345)
     at org.openxmlformats.schemas.wordprocessingml.x2006.main.StylesDocument$Factory.parse(Unknown Source)
     at org.apache.poi.xwpf.usermodel.XWPFDocument.getStyle(XWPFDocument.java:446)
     at org.apache.poi.xwpf.converter.core.styles.XWPFStylesDocument.&lt;init&gt;(XWPFStylesDocument.java:192)
     at org.apache.poi.xwpf.converter.core.styles.XWPFStylesDocument.&lt;init&gt;(XWPFStylesDocument.java:186)
     at org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.createStylesDocument(XWPFDocumentVisitor.java:161)
     at org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.&lt;init&gt;(XWPFDocumentVisitor.java:154)
     at org.apache.poi.xwpf.converter.pdf.internal.PdfMapper.&lt;init&gt;(PdfMapper.java:149)
     at org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:54)
     ... 4 more
  Caused by: org.xml.sax.SAXParseException; systemId: file:; lineNumber: 1; columnNumber: 1; Unexpected end of file after null
     at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.reportFatalError(Piccolo.java:1038)
     at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:723)
     at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3439)
     ... 15 more
  </code></pre>
  
  <p>Here goes the code how I convert it:</p>
  
  <pre><code>// 1) Load docx with POI XWPFDocument
  XWPFDocument document = new XWPFDocument(new FileInputStream(new File(docxFile)));
  XWPFDocument template = new XWPFDocument(new FileInputStream(new File("Template.dotx")));
  XWPFStyles newStyles = document.createStyles();
  newStyles.setStyles(template.getStyle());
  
  // 2) Convert POI XWPFDocument 2 PDF with iText
  File outFile = new File(pdfFile);
  OutputStream out = new FileOutputStream( outFile );
  PdfOptions options = null;
  PdfConverter.getInstance().convert( document, out, options );
  </code></pre>
  
  <p>However if I open file in word and save it again - I can convert without issues.
  Any suggestions?</p>