使用JAVA pdf转word

使用spire.pdf 非常简单。

查看 https://mvnrepository.com/artifact/e-iceblue/spire.pdf

注意,这个包在 e-iceblue 下。

下面开始撸代码

先来pom.xml

XML 复制代码
<?xml version="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.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>pdfToWord</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>e-iceblue</groupId>
            <artifactId>spire.pdf</artifactId>
            <version>9.10.3</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>com.e-iceblue</id>
            <url>https://repo.e-iceblue.cn/repository/maven-public/</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>public</id>
            <name>aliyun nexus</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
</project>

java代码。App.java

bash 复制代码
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要配置

bash 复制代码
	<mirror>
		<id>aliyunmaven</id>
		<mirrorOf>*,!com.e-iceblue</mirrorOf>
		<name>阿里云公共仓库</name>
		<url>https://maven.aliyun.com/repository/public</url>
	</mirror>
相关推荐
码农水水1 天前
米哈游Java面试被问:机器学习模型的在线服务和A/B测试
java·开发语言·数据库·spring boot·后端·机器学习·word
10km1 天前
MCP:Trace IDE 正确配置 PDF 读取 MCP 的完整指南
ide·pdf·mcp·trae
开开心心_Every1 天前
A3试卷分割工具:免费转为A4格式可离线
游戏·随机森林·微信·pdf·excel·语音识别·最小二乘法
萧炎火1 天前
word另存为html后用浏览器打开不显示图片
word
骆驼爱记录1 天前
Excel数据源到Word成绩单自动生成
自动化·word·excel·wps·新人首发
seasonsyy1 天前
Word 2010文档实现护眼效果
word
weixin_462446231 天前
使用 PaddleOCR + 多进程 + GPU 加速实现 PDF 可搜索化(支持中英文、竖排/旋转文字)
pdf·paddle·识别
DS随心转小程序1 天前
ai转pdf
人工智能·pdf·aigc·deepseek·ds随心转
开开心心_Every1 天前
手机PDF处理工具:支持格式转换与批注
游戏·微信·智能手机·pdf·逻辑回归·excel·语音识别
weixin_462446231 天前
用 Python 自动生成双面打印英语单词闪卡(Flashcards)PDF
python·pdf·记忆卡