使用spire.pdf 非常简单。
查看 https://mvnrepository.com/artifact/e-iceblue/spire.pdf
注意,这个包在 e-iceblue 下。
下面开始撸代码
先来pom.xml
- "1.0" encoding="UTF-8"?>
- <project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0modelVersion>
-
- <groupId>org.examplegroupId>
- <artifactId>pdfToWordartifactId>
- <version>1.0-SNAPSHOTversion>
-
- <properties>
- <maven.compiler.source>8maven.compiler.source>
- <maven.compiler.target>8maven.compiler.target>
- properties>
-
- <dependencies>
- <dependency>
- <groupId>e-icebluegroupId>
- <artifactId>spire.pdfartifactId>
- <version>9.10.3version>
- dependency>
- dependencies>
-
- <repositories>
- <repository>
- <id>com.e-iceblueid>
- <url>https://repo.e-iceblue.cn/repository/maven-public/url>
- repository>
- repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <id>publicid>
- <name>aliyun nexusname>
- <url>http://maven.aliyun.com/nexus/content/groups/public/url>
- <releases>
- <enabled>trueenabled>
- releases>
- <snapshots>
- <enabled>falseenabled>
- snapshots>
- pluginRepository>
- pluginRepositories>
- project>
java代码。App.java
- import com.spire.pdf.FileFormat;
- import com.spire.pdf.PdfDocument;
-
- import java.io.*;
-
- public class App {
- public static void main(String[] args) {
- // 加载pdf文件
- PdfDocument pdf = new PdfDocument();
- pdf.loadFromFile("Django基础教程.pdf");
- //保存为Excel文档
- pdf.saveToFile("Django基础教程.docx", FileFormat.DOCX);
- pdf.dispose();
-
- }
- }
注意: maven的setting.xml要配置
-
- <id>aliyunmaven
-
*,!com.e-iceblue -
阿里云公共仓库 -
https://maven.aliyun.com/repository/public -