准备工作
服务器安装libreoffice
apt-get install libreoffice
安装完成libreoffice后,测试是否安装成功
soffice -h
例子
把/tmp/ test.docx 转换成 /tmp/test.pdf
python例子
dic = '/tmp/'
basename1="test.docx"
cmd = "soffice --headless --invisible --convert-to pdf " + basename1
p = subprocess.Popen([cmd], cwd=dic, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, executable='/bin/bash')
for line in p.stdout.readlines():
print("returned_output:", line)
p.wait()
shell
cd /tmp
soffice --headless --invisible --convert-to pdf test.docx
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)