Occasionally, you might be in a sitution where you need to extract table from a PDF document and save the table date either in a Word file or in an Excel worksheet, so that you can edit the date freely. In this article, I am going to show you how to convert a whole PDF document to Excel or Word by usingSpire.PDF for Java.
Below is a screenshot of the input file.
Install Spire.Pdf.jar
If you’re creating a Maven project, you can easily add the jar in your applciation using the following configurations. For non-Maven projects, download the jar file fromthis link and add it as a dependency in your applicaiton.
<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><version>3.8.5</version></dependency></dependencies>
Convert PDF to Excel (XLS/XLSX)
publicclassConvertPdfToExcel{publicstaticvoidmain(String[]args){//Create a PdfDocument instancePdfDocumentpdf=newPdfDocument();//Load a PDF filepdf.loadFromFile("C:\\Users\\Administrator\\Desktop\\table.pdf");//Save as Excel filepdf.saveToFile("ToExcel.xlsx",FileForma.XLSX);}}
Convert PDF to Word (DOC/DOCX)
publicclassConvertPdfToWord{publicstaticvoidmain(String[]args){//Create a PdfDocument instancePdfDocumentpdf=newPdfDocument();//Load a PDF filepdf.loadFromFile("C:\\Users\\Administrator\\Desktop\\table.pdf");//Save as Word filepdf.saveToFile("ToWord.docx",FileFormat.DOCX);}}
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse