pdf转word

完了,新年第一天老婆喊我找个免费的转换软件帮她转一下dpf,我倒是找了些个在线免费转化的,也找了些免费的软件但是不是现在页数就是需要开会员,要么就限制大小,好吧,程序员嘛能省一块钱是一块钱,,能白嫖哎就白嫖下吧。新的一年希望祖国经济好起来,也预祝大家新年快乐,身体健康,万事如意。

免费在线转:https://www.alltoall.net/

pom插件、包引入、测试类,jar包

通过网盘分享的文件:aspose-pdf-21.6.jar

链接: https://pan.baidu.com/s/1XNS-FkWO1ztnRy-0HVMEeQ 提取码: 1deq

复制代码
 <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-install-plugin</artifactId>
            <version>2.5.2</version>
            <executions>
                <execution>
                    <id>install-pdf</id>
                    <phase>clean</phase>
                    <configuration>
                        <file>${pom.basedir}/src/resources/lib/aspose-pdf-21.6.jar</file>
                        <repositoryLayout>default</repositoryLayout>
                        <groupId>com.aspose</groupId>
                        <artifactId>aspose-pdf</artifactId>
                        <version>21.6</version>
                        <packaging>jar</packaging>
                        <generatePom>true</generatePom>
                    </configuration>
                    <goals>
                        <goal>install-file</goal>
                    </goals>
                </execution>
            </executions>
 </plugin>


 <!--pdf转word-->
        <dependency>
            <groupId>com.aspose</groupId>
            <artifactId>aspose-pdf</artifactId>
            <version>21.6</version>
        </dependency>

import com.aspose.pdf.Document;
import com.aspose.pdf.SaveFormat;

import java.io.*;

/**
 * Description PDF转word工具类
 *
 * @author wsm
 * @date 2025.01.01 0:20
 */
public class PDFToWordHelperUtil {

    public static void main(String[] args) throws IOException {
         pdf2doc("C:\\Users\\wangsm\\Desktop\\目录\\W020120410330232398521.pdf");
    }


    //pdf转doc
    public static void pdf2doc(String pdfPath) {
        long old = System.currentTimeMillis();
        try {
            //新建一个word文档
            String wordPath=pdfPath.substring(0,pdfPath.lastIndexOf("."))+".docx";
            FileOutputStream os = new FileOutputStream(wordPath);
            //doc是将要被转化的word文档
            Document doc = new Document(pdfPath);
            //全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF 相互转换
            doc.save(os, SaveFormat.DocX);
            os.close();
            //转化用时
            long now = System.currentTimeMillis();
            System.out.println("Pdf 转 Word 共耗时:" + ((now - old) / 1000.0) + "秒");
        } catch (Exception e) {
            System.out.println("Pdf 转 Word 失败...");
            e.printStackTrace();
        }
    }


}

来自:https://blog.csdn.net/qq_32419139/article/details/126972014

相关推荐
superlls26 分钟前
(计算机网络)JWT三部分及 Signature 作用
java·开发语言·计算机网络
多工坊34 分钟前
【DataGrip】连接达梦数据库后,能查询数据但是看不到表的几种情况分析,达梦数据库驱动包下载DmJdbcDriver18.jar
java·数据库·jar
秋难降1 小时前
优雅的代码是什么样的?🫣
java·python·代码规范
现在就干1 小时前
Spring事务基础:你在入门时踩过的所有坑
java·后端
浮游本尊2 小时前
Java学习第13天 - 数据库事务管理与MyBatis Plus
java
该用户已不存在2 小时前
Gradle vs. Maven,Java 构建工具该用哪个?
java·后端·maven
浮游本尊2 小时前
Java学习第11天 - Spring Boot高级特性与实战项目
java
浮游本尊2 小时前
Java学习第12天 - Spring Security安全框架与JWT认证
java
David爱编程2 小时前
happens-before 规则详解:JMM 中的有序性保障
java·后端
小张学习之旅2 小时前
ConcurrentHashMap
java·后端