title: Converting a pdf to word document using java
body: <p>I've successfully converted JPEG to Pdf using Java, but don't know how to convert Pdf to Word using Java, the code for converting JPEG to Pdf is given below.</p>
  
  <p>Can anyone tell me how to convert Pdf to Word (.doc/ .docx) using Java?</p>
  
  <pre><code>import java.io.FileOutputStream;
  import com.itextpdf.text.Image;
  import com.itextpdf.text.pdf.PdfWriter;
  import com.itextpdf.text.Document;
  
  public class JpegToPDF {
      public static void main(String[] args) {
          try {
              Document convertJpgToPdf = new Document();
              PdfWriter.getInstance(convertJpgToPdf, new FileOutputStream(
                      "c:\\java\\ConvertImagetoPDF.pdf"));
              convertJpgToPdf.open();
              Image convertJpg = Image.getInstance("c:\\java\\test.jpg");
              convertJpgToPdf.add(convertJpg);
              convertJpgToPdf.close();
              System.out.println("Successfully Converted JPG to PDF in iText");
          } catch (Exception i1) {
              i1.printStackTrace();
          }
      }
  }
  </code></pre>