使用OpenOffice将office文件转为pdf

0.参考博客:https://blog.csdn.net/weixin_39468112/article/details/89203815
1.首先安装openOffice4.1
2.添加依赖

<dependency>
<groupId>org.jodconverter</groupId>
<artifactId>jodconverter-core</artifactId>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>org.jodconverter</groupId>
<artifactId>jodconverter-local</artifactId>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>org.jodconverter</groupId>
<artifactId>jodconverter-spring-boot-starter</artifactId>
<version>4.2.2</version>
</dependency>

3.yaml配置软件安装路径(如果在生产环境需提前安装好OpenOffice)

#office转pdf,office-home如果项目部署在linux上记得修改
jodconverter:
local:
enabled: true
#centos7要先安装openOffice
office-home: C:\Program Files (x86)\OpenOffice 4
max-tasks-per-process: 10
port-numbers: 8100

4.使用:

@Autowired
DocumentConverter converter;
converter.convert(sourceFile).to(pdfFile).execute();

5.报错解决:一般是项目目录有中文的原因

posted @   LHX2018  阅读(472)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示