使用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>
相关推荐
xingxing_F19 小时前
PDF Protector for mac PDF文档加密解密工具
macos·pdf
985小水博一枚呀21 小时前
【AI大模型学习路线】第三阶段之RAG与LangChain——第十九章(实战基于Advanced RAG的PDF问答)系统部署与测试?
人工智能·学习·langchain·pdf
励志成为美貌才华为一体的女子1 天前
本地用docling实现pdf转markdown操作笔记
笔记·pdf
星空的资源小屋1 天前
RoboIntern,一款自动化办公小助手
运维·人工智能·pdf·自动化·电脑·excel
mucheni1 天前
迅为RK3568开发板OpenHarmony系统南向驱动开发手册-pdf配置 rk3568_uart_config.hcs
驱动开发·pdf
ONLYOFFICE1 天前
ONLYOFFICE 桌面编辑器9.1版本已发布:PDF密文功能和全新注释、工作表公式优化及文件恢复便捷化等
pdf·编辑器·onlyoffice 模板
Aevget2 天前
DevExpress WinForms v25.1亮点 - PDF Viewer(查看器)等全新升级
pdf·c#·界面控件·winform·devexpress·ui开发
企鹅侠客2 天前
基于python写的PDF表格提取到excel文档
python·pdf·excel·pdf文档表格转excel
chenchihwen2 天前
深度解析RAG系统中的PDF解析模块:Docling集成与并行处理实践
python·算法·pdf
Uluoyu2 天前
word、pdf文档内容提取工具类
java·pdf·word