在 CentOS 上使用 LibreOffice(你写的 liboffice 通常是 LibreOffice),一般包括安装、启动、命令行转换文档等用法。下面按常见场景说明。
sudo yum install libreoffice
或(CentOS 8+):
sudo dnf install libreoffice
这会安装完整套件(Writer、Calc、Impress 等)。
例如只装 Writer 和 Calc:
sudo yum install libreoffice-writer libreoffice-calc
如果你使用的是 GNOME / KDE 等桌面环境:
libreoffice
或分别启动:
libreoffice --writer
libreoffice --calc
libreoffice --impress
也可以从菜单里找 LibreOffice。
例如把 Word 转 PDF:
libreoffice --headless --convert-to pdf test.docx
转 Excel:
libreoffice --headless --convert-to pdf test.xlsx
指定输出目录:
libreoffice --headless --convert-to pdf --outdir /tmp test.docx
通常是:
可加参数:
libreoffice --headless --nofirststartwizard --convert-to pdf test.docx
或在服务中使用独立用户目录:
libreoffice --headless -env:UserInstallation=file:///tmp/lo --convert-to pdf test.docx
libreoffice --version
sudo yum remove libreoffice*
如果你告诉我:
我可以给你更针对性的命令。