An Interest In:
Web News this Week
- January 13, 2021
- January 12, 2021
- January 11, 2021
- January 10, 2021
- January 9, 2021
- January 8, 2021
- January 7, 2021
January 13, 2021 06:47 am GMT
Original Link: https://dev.to/jazzzzz/convert-pdf-to-word-document-using-java-419n
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.
<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.free</artifactId> <version>3.9.0</version> </dependency></dependencies>
Enter fullscreen mode Exit fullscreen mode
The original PDF document is shown as below:
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 doc.saveToFile("output/ToDoc.doc",FileFormat.DOC); //Save as. docx file doc.saveToFile("output/ToDocx.docx",FileFormat.DOCX); doc.close(); }}
Enter fullscreen mode Exit fullscreen mode
Original Link: https://dev.to/jazzzzz/convert-pdf-to-word-document-using-java-419n
Share this article:
Tweet
View Full Article

Dev To

More About this Source Visit Dev To