使用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>
相关推荐
geovindu14 分钟前
python: 简单提取PDF文档内文字
开发语言·python·pdf
m0_6948455720 分钟前
HandBrake 是什么?视频转码工具使用与服务器部署教程
服务器·前端·pdf·开源·github·音视频
yivifu18 小时前
使用PyMuPdf删除PDF文档中的水印
pdf·pymupdf·去水印
星尘库18 小时前
在word中怎么把段落回车替换成空 删除空行
word
weixin_4166600718 小时前
AI 导出 Word 不正规?10 类文档样式模板(可直接套用,含字体/字号/行距/缩进)
人工智能·word·论文·排版·数学公式
ComPDFKit19 小时前
ComPDF的产品升级:从工具包到PDF服务
pdf
占疏1 天前
pdf文件解析
pdf
开开心心_Every1 天前
音频视频转文字工具,离线语音识别免费
人工智能·游戏·微信·pdf·excel·语音识别·memcache
开开心心_Every1 天前
电脑网速加速工具,无线有线叠加网络
网络·游戏·微信·pdf·电脑·excel·语音识别
小沈同学呀1 天前
SpringBoot 使用Docx4j实现 DOCX 转 PDF
spring boot·后端·pdf·docx4j