title: Apache poi converter is not showing the table borders lines after converting
body: <p>I am having an issue when using Apache POI to create a DOC file, then convert to PDF.</p>
  
  <p>Using Apache POI to create a DOC file works well, it outputs a DOC with text, tables, imagery and shaded headers without problems. If I use IText to create the PDF this also works.</p>
  
  <p>I am trying to reduce development and change time by creating a DOC then converting this to PDF so that I do not have two code bases to manage.</p>
  
  <p>When I convert the DOC to PDF using Apache POI converter, I got the Style Error. </p>
  
  <pre><code>org.apache.poi.xwpf.converter.core.XWPFConverterException: java.lang.IllegalStateException: Expecting one Styles document part, but found 0
  </code></pre>
  
  <p>I add the style in the code. but then get this error: </p>
  
  <p>I also get a null pointer exception relating to the headers, error below:
      ERROR CODE</p>
  
  <pre><code>org.apache.poi.xwpf.converter.core.XWPFConverterException: java.lang.NullPointerException
   at org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:70) ~[org.apache.poi.xwpf.converter.pdf-1.0.6.jar:1.0.6]
   at org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:38) ~[org.apache.poi.xwpf.converter.pdf-1.0.6.jar:1.0.6]
   at org.apache.poi.xwpf.converter.core.AbstractXWPFConverter.convert(AbstractXWPFConverter.java:45) ~[org.apache.poi.xwpf.converter.core-1.0.6.jar:1.0.6]
   at com.imviewer.report.DocxReportBuilder311CUSTOM.ConvertToPDF(DocxReportBuilder311CUSTOM.java:878) [classes/:na]
   at com.imviewer.report.DocxReportBuilder311CUSTOM.doInBackground(DocxReportBuilder311CUSTOM.java:833) [classes/:na]
   at com.imviewer.report.DocxReportBuilder311CUSTOM.doInBackground(DocxReportBuilder311CUSTOM.java:1) [classes/:na]
   at javax.swing.SwingWorker$1.call(Unknown Source) [na:1.8.0_161]
   at java.util.concurrent.FutureTask.run(Unknown Source) [na:1.8.0_161]
   at javax.swing.SwingWorker.run(Unknown Source) [na:1.8.0_161]
   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_161]
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_161]
   at java.lang.Thread.run(Unknown Source) [na:1.8.0_161]
  Caused by: java.lang.NullPointerException: null
   at org.apache.poi.xwpf.converter.core.utils.XWPFTableUtil.getGridColList(XWPFTableUtil.java:183) ~[org.apache.poi.xwpf.converter.core-1.0.6.jar:1.0.6]
   at org.apache.poi.xwpf.converter.core.utils.XWPFTableUtil.computeColWidths(XWPFTableUtil.java:116) ~[org.apache.poi.xwpf.converter.core-1.0.6.jar:1.0.6]
   at org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.visitTable(XWPFDocumentVisitor.java:867) ~[org.apache.poi.xwpf.converter.core-1.0.6.jar:1.0.6]
   at org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.visitBodyElements(XWPFDocumentVisitor.java:251) ~[org.apache.poi.xwpf.converter.core-1.0.6.jar:1.0.6]
   at org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.start(XWPFDocumentVisitor.java:199) ~[org.apache.poi.xwpf.converter.core-1.0.6.jar:1.0.6]
   at org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:56) ~[org.apache.poi.xwpf.converter.pdf-1.0.6.jar:1.0.6]
   ... 11 common frames omitted
  </code></pre>
  
  <p>Then I have tried manually converting the DOC to PDF using Apache POI in a separate piece of code the text is output and tables/imagery appear to be in the correct place but no table lines show (although the spacing appears correct). However, if I open the created DOC, remove the table formatting, then re-apply, then convert the DOC to PDF, the lines appear.</p>
  
  <p>It seems that the lines which show in the DOC created by Apache POI will not convert or show in a PDF converted by Apache - but, if we manually add table formatting it does show.</p>
  
  <p>Can anyone help please?</p>
  
  <pre><code>public static void ConvertToPDF(File docPath, File pdfPath) {
          try {
              InputStream doc = new FileInputStream(docPath);
              XWPFDocument document = new XWPFDocument(doc);
              PdfOptions options = PdfOptions.create();
              OutputStream out = new FileOutputStream(pdfPath);
              PdfConverter.getInstance().convert(document, out, options);
              System.out.println("Completed");
          } catch (IOException ex) {
              System.out.println(ex.getMessage());
          }
      }
  </code></pre>
  
  <p>The Library Version Im using is:
  <a href="https://i.stack.imgur.com/l56Py.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l56Py.png" alt="enter image description here"></a></p>