Linux下使用libreoffice把doc转换成Pdf

2 篇文章 0 订阅

先安装libreoffice,然后使用命令

soffice --headless --invisible --convert-to pdf /tmp/abc.docx --outdir /tmp/

转换成PDF,几乎所有人都遇到


root@panda-dev:~/bin $ soffice --headless --convert-to txt:text blah.doc
/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)

类似的问题,网上的帮助都是说要求启用:


/usr/bin/soffice --headless --accept="socket,host=127.0.0.1,port=8100;urp;" --nofirststartwizard &


然后 export DISPLAY=:0.0,就可以解决问题,但试了N次也完全不行。


其实只需要 yum install libreoffice-headless,即可。


  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值