linux(ubuntu&centos)-安装libreoffice

因为需要在linux支持word文档和pdf之间的转换,调研验证后选择了libreoffice,在不同的服务器进行了安装,记录如下。

说明:

此处下载版本是7.6.7,如果网址不存在,可以访问http://mirrors.ustc.edu.cn/tdf/libreoffice/stable 找到能下载的版本号,替换即可

ubuntu安装

bash 复制代码
#0.新建文件夹
mkdir /data1/janee/libreoffice
cd /data1/janee/libreoffice
#1.下载包
wget http://mirrors.ustc.edu.cn/tdf/libreoffice/stable/7.6.7/deb/x86_64/LibreOffice_7.6.7_Linux_x86-64_deb.tar.gz
wget http://mirrors.ustc.edu.cn/tdf/libreoffice/stable/7.6.7/deb/x86_64/LibreOffice_7.6.7_Linux_x86-64_deb_sdk.tar.gz
wget http://mirrors.ustc.edu.cn/tdf/libreoffice/stable/7.6.7/deb/x86_64/LibreOffice_7.6.7_Linux_x86-64_deb_langpack_zh-CN.tar.gz
#2.解压和安装
mkdir deb
tar -zxvf LibreOffice_7.6.7_Linux_x86-64_deb.tar.gz -C deb
tar -zxvf LibreOffice_7.6.7_Linux_x86-64_deb_sdk.tar.gz -C deb
tar -zxvf LibreOffice_7.6.7_Linux_x86-64_deb_langpack_zh-CN.tar.gz -C deb
cd deb
sudo dpkg -i LibreOffice_7.6.7.2_Linux_x86-64_deb/DEBS/*.deb
sudo dpkg -i LibreOffice_7.6.7.2_Linux_x86-64_deb_sdk/DEBS/*.deb
sudo dpkg -i LibreOffice_7.6.7.2_Linux_x86-64_deb_langpack_zh-CN/DEBS/*.deb
#3.测试,此处放置了文件"测试样例.docx"
cd /data1/janee 
libreoffice7.6 --headless --convert-to doc 测试样例.docx
libreoffice7.6 --headless --convert-to pdf 测试样例.docx

centos安装方式

bash 复制代码
#1.下载包
wget https://mirrors.ustc.edu.cn/tdf/libreoffice/stable/7.6.7/rpm/x86_64/LibreOffice_7.6.7_Linux_x86-64_rpm.tar.gz
#放在:/data1/janee/libreoffice/LibreOffice_7.6.7_Linux_x86-64_rpm.tar.gz
#2.解压和安装
cd /data1/janee/libreoffice
tar -zxvf LibreOffice_7.6.7_Linux_x86-64_rpm.tar.gz
sudo yum install ./LibreOffice_7.6.7_Linux_x86-64_rpm/RPMS/*.rpm
#安装后在/opt/libreoffice7.6/program
#3.设置路径
vim /etc/profile
# 在文档底部添加如下内容:
# libreoffice
export LibreOffice_PATH=/opt/libreoffice7.6/program
export PATH=$LibreOffice_PATH:$PATH
# source /etc/profile 使得配置生效
#4.测试,在/data1/janee放了文档"测试样例.docx"
cd /data1/janee 
libreoffice7.6 --headless --convert-to doc 测试样例.docx
libreoffice7.6 --headless --convert-to pdf 测试样例.docx

备忘:

1.参考博文时rpm包,有提到建立后台服务,因为我的需求是命令转换即可,所以没有完成该步骤。只是按照上述笔记走通了文件转换流程。

2.ubuntu和centos需要不同的安装方式是在/data1/janee/libreoffice/LibreOffice_7.6.7.2_Linux_x86-64_deb/readmes/README_en-US 看到的。

参考博客:

Python在Linux环境下Word转PDF_python linux word转pdf-CSDN博客

Windows/Linux环境下安装并使用Libreoffice(SpingBoot 整合Libreoffice)&Linux字体库新增字体_libreoffice online websocket for windows-CSDN博客

相关推荐
我的xiaodoujiao1 小时前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 38--Allure 测试报告
python·学习·测试工具·pytest
沈浩(种子思维作者)7 小时前
真的能精准医疗吗?癌症能提前发现吗?
人工智能·python·网络安全·健康医疗·量子计算
C_心欲无痕7 小时前
ts - tsconfig.json配置讲解
linux·前端·ubuntu·typescript·json
njsgcs8 小时前
ue python二次开发启动教程+ 导入fbx到指定文件夹
开发语言·python·unreal engine·ue
io_T_T8 小时前
迭代器 iteration、iter 与 多线程 concurrent 交叉实践(详细)
python
冰西瓜6008 小时前
国科大2025操作系统高级教程期末回忆版
linux
华研前沿标杆游学8 小时前
2026年走进洛阳格力工厂参观游学
python
Carl_奕然8 小时前
【数据挖掘】数据挖掘必会技能之:A/B测试
人工智能·python·数据挖掘·数据分析
HIT_Weston8 小时前
93、【Ubuntu】【Hugo】搭建私人博客:面包屑(一)
linux·运维·ubuntu
AI小怪兽9 小时前
基于YOLOv13的汽车零件分割系统(Python源码+数据集+Pyside6界面)
开发语言·python·yolo·无人机