在 CentOS 下使用 LibreOffice,一般流程如下:
sudo yum install libreoffice
或(CentOS 8+):
sudo dnf install libreoffice
如需完整组件:
sudo dnf groupinstall "LibreOffice"
libreoffice --version
或
soffice --version
如果服务器有 GNOME / KDE 桌面:
libreoffice
或开始菜单中搜索 LibreOffice
可新建:
libreoffice test.docx
例如 Word 转 PDF:
libreoffice --headless --convert-to pdf test.docx
Excel 转 PDF:
libreoffice --headless --convert-to pdf test.xlsx
指定输出目录:
libreoffice --headless --convert-to pdf --outdir /tmp test.docx
for f in *.docx; do
libreoffice --headless --convert-to pdf "$f"
done
尝试:
soffice
或:
/usr/bin/soffice
安装中文字体:
sudo yum install wqy-zenhei-fonts
确保没有 libreoffice 图形界面在运行:
pkill libreoffice
sudo yum remove libreoffice*
如果你有 具体用途(比如:服务器自动转 PDF、Java/PHP 调用、无桌面环境部署),可以告诉我,我可以给你更针对性的方案。