SpringBoot文件转换实现(word到pdf)

SpringBoot实现word到pdf文件转换

SpringBoot文件转换实现

方案

jodconverter+libreoffice

前置条件

需要安装 LibreOfficePortable

获取地址1:主页 | LibreOffice 简体中文官方网站 - 自由免费的办公套件

获取地址2:https://www.libreoffice.org/

具体下载可以查询一下,这两个地址是官网(第一个应该是吧?)

pom 文件

<dependency>
    <groupId>org.jodconverter</groupId>
    <artifactId>jodconverter-core</artifactId>
    <version>4.2.0</version>
</dependency>
<dependency>
    <groupId>org.jodconverter</groupId>
    <artifactId>jodconverter-local</artifactId>
    <version>4.2.0</version>
</dependency>
<dependency>
    <groupId>org.jodconverter</groupId>
    <artifactId>jodconverter-spring-boot-starter</artifactId>
    <version>4.2.0</version>
</dependency>
<dependency>
    <groupId>org.libreoffice</groupId>
    <artifactId>ridl</artifactId>
    <version>5.4.2</version>
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <optional>true</optional>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>

配置文件

jodconverter.local.office-home是LibreOfficePortable在windows的安装地址下的\App\libreoffice
${user.dir}是项目根目录

jodconverter.local.enabled=true
jodconverter.local.office-home=${user.dir}\\LibreOfficePortable\\App\\libreoffice
jodconverter.local.office-home-linux=${user.dir}\\LibreOfficePortable\\App/libreoffice
jodconverter.local.portNumbers=9080,9081,9089
jodconverter.local.maxTasksPerProcess=100

配置类

JodConverterConfig

package org.example.fileconvertdemo.config;

import org.jodconverter.DocumentConverter;
import org.jodconverter.LocalConverter;
import org.jodconverter.office.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值