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.
SpringBoot实现word到pdf文件转换

最低0.47元/天 解锁文章
21万+

被折叠的 条评论
为什么被折叠?



