LibreOffice 下载、Linux安装、启动、Java集成pdf转换
下载
官网中文主页:https://zh-cn.libreoffice.org/
点击下载,可选Linux、macOS、Windows三大类及其不同处理器对应的定制包
本次在Linux安装使用 LibreOffice_7.3.3_Linux_x86-64_rpm.tar.gz
安装
上传
将安装包放到Linux上
解压
tar -xvf LibreOffice_7.3.3_Linux_x86-64_rpm.tar.gz
安装
进入RPMS文件夹中,
cd LibreOffice_7.1.2_Linux_x86-64_rpm/RPMS
yum localinstall *.rpm
安装过程中遇到选择,输入 y 回车
安装成功后会在 /opt/
下生产一个 libreoffice7.3
的文件夹
启动
后台启动
nohup libreoffice7.3 --headless --accept="socket,host=0.0.0.0,port=8101;urp;" --nofirststartwizard &
启动时会把pid打到这行命令下面
测试
Linux本地测试文档转换命令:
/opt/libreoffice7.3/program/soffice --headless --invisible --convert-to pdf /opt/test.txt --outdir /opt
查看进程
ps -ef|grep libre展示3个进程,第3个不算,如下root 1459 789 0 12:08 pts/4 00:00:00 /opt/libreoffice7.3/program/oosplash --headless --accept=socket,host=0.0.0.0,port=8101;urp; --nofirststartwizard
root 1512 1459 0 12:08 pts/4 00:00:01 /opt/libreoffice7.3/program/soffice.bin --headless --accept=socket,host=0.0.0.0,port=8101;urp; --nofirststartwizard
root 7709 789 0 13:45 pts/4 00:00:00 grep --color=auto libre
查看端口占用
lsof -i:8101展示如下
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
soffice.b 1512 root 14u IPv4 82428014 0t0 TCP *:ldoms-migr (LISTEN)
卸载
你可以尝试 yum erase libreoffice*
或者 yum remove openoffice.org* libreoffice.org*
Java集成
工具包版
maven依赖
<dependency><groupId>com.artofsolving</groupId><artifactId>jodconverter</artifactId><version>2.2.1</version></dependency>
测试代码
package com.oxye;import com.artofsolving.jodconverter.DefaultDocumentFormatRegistry;
import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.DocumentFormat;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.StreamOpenOfficeDocumentConverter;
import lombok.extern.slf4j.Slf4j;import java.io.*;
import java.net.ConnectException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;@Slf4j
public class ConvertUtil {public static void main(String[] args) throws IOException {convert("E:\\tmp1\\wsnd.txt", "E:\\tmp1\\test.pdf");}public static void convert(String fromPath, String toPath) {File fromFile = new File(fromPath);if (!fromFile.exists()) {log.error("源文件不存在");return;}File toFile = new File(toPath);SocketOpenOfficeConnection connection = new SocketOpenOfficeConnection("你滴ip", 你设置滴端口号);try {connection.connect();StreamOpenOfficeDocumentConverter converter = new StreamOpenOfficeDocumentConverter(connection);converter.convert(fromFile, toFile);} catch (ConnectException e) {log.error("获取连接失败", e);} finally {if (connection.isConnected()) {connection.disconnect();}}}
}
SpringBoot starter版
maven依赖
SpringBoot starter
<dependency><groupId>org.jodconverter</groupId><artifactId>jodconverter-spring-boot-starter</artifactId><version>4.4.2</version></dependency><dependency><groupId>org.jodconverter</groupId><artifactId>jodconverter-core</artifactId><version>4.4.2</version></dependency><dependency><groupId>org.jodconverter</groupId><artifactId>jodconverter-local</artifactId><version>4.4.2</version></dependency><dependency><groupId>org.jodconverter</groupId><artifactId>jodconverter-remote</artifactId><version>4.4.2</version></dependency>
自动装配配置类,可以看出有两种模式,local是调用本地的,remote是远程的,docker启openoffice online才能用
org.jodconverter.boot.autoconfigure.JodConverterLocalAutoConfiguration
org.jodconverter.boot.autoconfigure.JodConverterLocalProperties
org.jodconverter.boot.autoconfigure.JodConverterRemoteAutoConfiguration
org.jodconverter.boot.autoconfigure.JodConverterRemoteProperties
先不考虑这个,项目要集群,不能使用local模式;也不使用docker,不能使用remote模式
LibreOffice 下载、Linux安装、启动、Java集成pdf转换相关推荐
- linux中启动 java -jar 后台运行程序
ps -ef | grep java 查询java 端口占用 linux中启动 java -jar 后台运行程序 直接用java -jar xxx.jar,当退出或关闭shell时,程序就会停止掉. ...
- JAVA实现 PDF转换 常用工具类(html转PDF、PDF添加页码、PDF文件下载、PDF添加印章或者水印)
JAVA实现 PDF转换 常用工具类(html转PDF.PDF添加页码.PDF文件下载.PDF添加印章或者水印)可直接使用 package com.bestvike.util; import com. ...
- java版 pdf转换_java如何将pdf转换成image
java如何将pdf转换成image 发布时间:2020-08-26 03:05:15 来源:脚本之家 阅读:86 作者:yiluoak_47 本文实例为大家分享了java将pdf转换image的具体 ...
- Linux安装卸载java
方法一 进入 Oracle 官方网站 下载合适的 JDK 版本,准备安装. 注意:这里需要下载 Linux 版本.这里以jdk-8u151-linux-x64.tar.gz为例,你下载的文件可能不是这 ...
- SCALA Linux安装:JAVA.LANG.NUMBERFORMATEXCEPTION: FOR INPUT FOR INPUT STRING: “0X100“
SCALA安装:JAVA.LANG.NUMBERFORMATEXCEPTION: FOR INPUT FOR INPUT STRING: "0X100" 问题描述 Linux终端输 ...
- Windows中 JDK下载与安装教程 JAVA环境变量配置、JDK基本介绍
JDK基本介绍 JDK是 Java 语言的软件开发工具包,主要用于移动设备.嵌入式设备上的java应用程序.JDK是整个java开发的核心,它包含了JAVA的运行环境(JVM+Java系统类库)和J ...
- JDK下载与安装和Java开发环境变量的配置
这里我们先安装JDK再配置环境变量 1.下载JDK 安装JDK前先下载JDK这里我们前往官网下载即可:这里是JDK-7u80-windows-x64版本 Java Archive Downloads ...
- Microsoft SQL Server 2019 下载、安装及Java JDBC配置连接数据库(多图详解 超详细)
一.下载 下载链接Microsoft SQL Server 二.安装 1.找到刚刚下载的文件,双击打开后,选择基本并接受 2.选择接受 3.选择安装位置,并点击安装,然后等待下载安装完成 4.正在安装 ...
- 如何在linux部署pdf文档,LINUX安装部署文档.pdf
LINUX 安装部署详解文档 文档内容简介: 一:详解安装前的准备工作---------------------- 二:安装LINUX ---------------------------... 三 ...
最新文章
- MyBatis-Plus,搭配 Spring Boot 使用,一篇就够了
- 拜访了这位小哥的GitHub后,我失眠了!
- 科技部颁布十大国家新一代人工智能开放创新平台,华为旷视等入选
- linux+内核中开启nfs,NFS Client in Linux Kernel - Open
- boost::filesystem模块打印文件的大小的测试程序
- 十分好用的拓扑图插件JTopo
- 5大主流ASO优化工具
- 亿阳信通面试 亿阳信通笔试 面经大全
- Codeforces 235C. Cyclical Quest 后缀自动机
- iscript脚本截取字符串
- 怎么看服务器硬盘数据信息,如何查看服务器的硬盘数量
- JavaSearch搜索引擎
- 什么是领导者_为什么我们比以往更需要开放的领导者
- Chromium插件(Plugin)模块(Module)加载过程分析
- 【Python虫师】多窗口定位
- 谈谈我对Mac笔记本的使用感受
- 新玺配资:白酒醉了心 煤炭上了头
- Performer:Rethinking Attention with Performers(2020-9-30)
- Java基础短时自学总结
- 【运筹学】对偶理论 : 对称形式 ( 对称形式 | 对偶模型转化实例 | 对偶问题规律分析 )
热门文章
- php理财游戏源码,PHP理财 复利 分红 拆分经营养成类游戏源码
- poi中Numeric的理解
- Android之给自定义相机增加贴纸
- Vue.js系列之入门手册整理
- Do not use “// @ts-ignore“ because it alters compilation errors问题的处理
- win7搭建虚拟pppoe服务器,Win7在桌面建立一个pppoe宽带自动连接器的方法
- 番茄助手无法安装的问题
- 【面试系列】浅谈后端面试技巧
- [BZOJ3637][LCT]Qtree6
- “undefined reference to“ 问题汇总及解决方法