CentOS 6.9安装LibreOffice及字体安装及python调用

最近由于遇到了要使用预览的功能,然后有一个doc转PDF的需求,然后需要使用libreoffice的功能,然后使用 
soffice --headless --invisible --convert-to pdf /tmp/abc.docx --outdir /tmp/ 就可以安装了。

libreoffice安装

[root@CentOS~]# yum install libreoffice
[root@CentOS~]# yum install libreoffice-headless
  • 1
  • 2

字体安装

[root@CentOS~]# mkdir /usr/share/fonts/simsun
##拷贝windows中的simsun.ttc到/usr/share/fonts/simsun/
然后执行以下命令
[root@CentOS~]#cd /usr/share/fonts/simsun
[root@CentOS~]#mkfontscale
[root@CentOS~]#mkfontdir
[root@CentOS~]#fc-cache -fv
执行以下命令让字体生效

[root@CentOS~]#source /etc/profilesoffice --headless --invisible --convert-to pdf /tmp/abc.docx --outdir /tmp/######python调用借助libreoffice将doc进行格式转换
#!/usr/bin/env python
# coding:utf-8
import subprocess
output = subprocess.check_output(["soffice","--headless","--invisible","--convert-to","docx","/home/requiem/workspace/python3/test.doc","--outdir","/home/requiem/workspace/python3/"])
########################转自:https://blog.csdn.net/u011053407/article/details/74989837https://blog.csdn.net/qq_30371793/article/details/76578181

猜你喜欢

转载自blog.csdn.net/qq_41262248/article/details/80772019