1、centos下安装libreoffice
sudo yum install libreoffice
2、命令行执行word转pdf
将 /mnt/hgfs/test.docx目录下的test.docx转成pdf存放到 /mnt/hgfs 目录下:
libreoffice --headless --convert-to pdf:writer_pdf_Export /mnt/hgfs/test.docx --outdir /mnt/hgfs
3、如果出现以下错误
/usr/lib64/libreoffice/program/soffice.bin X11 error: Can't open display:
Set DISPLAY environment variable, use -display option
or check permissions of your X-Server
(See "man X" resp. "man xhost" for details)
-- 执行 sudo yum install libreoffice-headless即可
参考:
1、https://www.jb51.net/article/127358.htm
2、https://blog.csdn.net/pwtitle/article/details/51684685
网友评论