Linux下使用LibreOffice导出PDF的详细方法
多数Linux发行版(如Ubuntu、Fedora)默认包含LibreOffice,若未安装,可通过包管理器快速安装:
sudo apt-get update && sudo apt-get install libreoffice;sudo yum install libreoffice;sudo dnf install libreoffice。通过以下方式打开需要转换的文档(支持DOCX、ODT、RTF等格式):
在“PDF选项”对话框中,可根据需求自定义设置:
确认设置无误后,点击导出按钮。LibreOffice会将文档保存为PDF格式,文件默认保存至指定目录,原始文档不会被覆盖。
若需要批量转换文档(如.docx、.odt等),可使用LibreOffice的命令行工具,步骤如下:
cd /home/user/documents);libreoffice --headless --invisible --convert-to pdf input.docx/path/to/output目录):libreoffice --headless --invisible --convert-to pdf:writer_pdf_Export input.docx --outdir /path/to/outputlibreoffice --convert-to pdf --outdir /path/to/output --pdf-quality 100 --pdf-encrypt --pdf-user-pw "yourpassword" input.docx--headless表示无界面运行(后台处理),--invisible表示隐藏窗口;writer_pdf_Export指定导出格式为PDF(适用于Writer组件)。/usr/share/fonts目录,然后运行fc-cache -fv更新字体缓存;--headless参数)以避免阻塞终端。