title: Convert DOC [HWPFDocument] to pdf [with font, Table and images] using java
body: <p>converting doc file to pdf</p>
  
  <p>I am using the following code :</p>
  
  <pre><code>        POIFSFileSystem fs = null;
          Document Pdfdocument = new Document();
  
          fs = new POIFSFileSystem(new FileInputStream(srcFile));
          HWPFDocument doc = new HWPFDocument(fs);
          WordExtractor we = new WordExtractor(doc);
  
          PdfWriter writer = PdfWriter.getInstance(Pdfdocument, new 
          FileOutputStream(targetFile));
  
          Pdfdocument.open();
          writer.setPageEmpty(true);
          Pdfdocument.newPage();
          writer.setPageEmpty(true);
          String[] paragraphs = we.getParagraphText();
          for (int i = 0; i &lt; paragraphs.length; i++) {
              Pdfdocument.add(new Paragraph(paragraphs[i]));
          }
  </code></pre>
  
  <p>This generates a pdf without formatting and images 
  even fonts will be missing.</p>
  
  <p>Since <code>WordExtractor</code> uses only text
  is there any other way to convert with fonts and images.
  Convertion form  <strong>doc(<code>HWPFDocument</code>) but not on docx</strong></p>
  
  <p>I have referred these SO links</p>
  
  <p><a href="https://stackoverflow.com/q/17826401/6032482">Convert doc to pdf using Apache POI</a></p>
  
  <p><a href="https://stackoverflow.com/a/6210694/6032482">https://stackoverflow.com/a/6210694/6032482</a></p>
  
  <p><a href="https://stackoverflow.com/q/15636516/6032482">how to convert doc,docx files to pdf in java programatically</a></p>
  
  <p>and many more but found 
  they all use WordExtractor .</p>
  
  <p>Note:
  I can't use library office
  nor
  Aspose</p>
  
  <p>Can it be done using: </p>
  
  <blockquote>
    <p>ApachePOI </p>
    
    <p>DOCX4j </p>
    
    <p>itext</p>
  </blockquote>