1、下载安装

linux 下载rpm包

# wget https://mirrors.cloud.tencent.com/libreoffice/libreoffice/stable/7.0.6/rpm/x86_64/LibreOffice_7.0.6_Linux_x86-64_rpm.tar.gz

# wget https://mirrors.cloud.tencent.com/libreoffice/libreoffice/stable/7.0.6/rpm/x86_64/LibreOffice_7.0.6_Linux_x86-64_rpm_langpack_zh-CN.tar.gz

2、安装

# yum install ./LibreOffice_7.0.6.2_Linux_x86-64_rpm/RPMS/*.rpm

# yum install ./LibreOffice_7.0.6.2_Linux_x86-64_rpm_langpack_zh-CN/RPMS/*.rpm

# yum install ./LibreOffice_7.0.6.2_Linux_x86-64_rpm_helppack_zh-CN/RPMS/*.rpm

3、安装中文字体(由于linux默认没有安装中文字体 所以导出有中文的文件会导致中文乱码 )

这里安装微软雅黑

3.1查看是否安装中文字体

# fc-list :lang=zh //显示为空表示没有安装中文字体

3.2 将字体上传到服务器中 /usr/share/fonts目录

# cp MSYH.TTF /usr/share/fonts/

# cd /usr/share/fonts/ # mkfontscale # mkfontdir # fc-cache

# fc-list :lang=zh //查看是否安装成功

/usr/share/fonts/MSYH.TTF: Microsoft YaHei:style=Regular,Normal

4、将docx文件转化为pdf

libreoffice7.0 --invisible --language=zh-CN --convert-to pdf test.docx --outdir /home/data/libreOffice/