Convert PDF to Word Document using Java

This article will demonstrate how to convert a PDF to Word document with a 3rd party free Java API.

Import JAR Dependency (2 Methods)

● Download the Free API ( Free Spire.PDF for Java ) and unzip it, then add the Spire.Pdf.jar file to your project as dependency.

● Directly add the jar dependency to maven project by adding the following configurations to the pom.xml.


The original PDF document is shown as below:

1 Kt6wGn-UPfo66JKXXSI9LQ.jpg

Code Snippet

import com.spire.pdf.*;

public class ConvertPDF {
    public static void main(String[] args) {

        //Create a PdfDocument object
        PdfDocument doc = new PdfDocument();
        //Load the sample PDF file
        doc.loadFromFile("C:\\Users\\Administrator\\Desktop\\The Scarlet Letter.pdf");

        //Save as .doc file

        //Save as. docx file

The output Word document:

1 GjbiQwN7FwtmJ1PFuOxPgQ.jpg

Comments (1)

Anthony Hall's photo

thanks for the info. I will use it. In response, I would like to share a useful CoolUtils converter program. very cool program, easy to use, also affordable price and cool interface. So come on in, download, and enjoy.