Overview
The main benefit of converting PDFs to Word documents is the ability to edit the text directly within the file. This is especially helpful if you want to make significant changes to your PDF. If most data of your PDF are in tabular form, you can choose to convert it to an Excel spreadsheet. In the following sections, I will introduce how to convert searchable PDF to Word and Excel, and how to convert PDF to images as well by using Spire.PDF for Java.
Installing Spire.Pdf.jar
If you create a Maven project, you can easily import the jar in your application using the following configurations. For non-Maven projects, download the jar file from this link and manually add it as a dependency in your application.
- <repositories>
- <repository>
- <id>com.e-iceblue</id>
- <name>e-iceblue</name>
- <url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>
- </repository>
- </repositories>
- <dependencies>
- <dependency>
- <groupId> e-iceblue </groupId>
- <artifactId>spire.pdf</artifactId>
- <verson>4.1.2</version>
- </dependency>
- </dependencies>
Convert PDF to DOC or DOCX
Conversion from PDF to Word or Excel is quite straightforward by using this library. Create a PdfDocument object to load the original PDF document, and then call saveToFile() method to save PDF in .doc, .docx, .xls, or .xlsx file format.
- import com.spire.pdf.FileFormat;
- import com.spire.pdf.PdfDocument;
- public class ConvertPdfToWord {
- public static void main(String[] args) {
- //Create a PdfDocument instance
- PdfDocument pdf = new PdfDocument();
- //Load a PDF file
- pdf.loadFromFile("C:\\Users\\Administrator\\Desktop\\original.pdf");
- //Save to .docx file
- pdf.saveToFile("ToWord.docx", FileFormat.DOCX);
- pdf.close();
- }
- }

Join the conversation! Your thoughts help the community grow.