linux下doc轉docx


yum install libreoffice-writer

安裝 libreoffice

yum install libreoffice-headless
yum install libreoffice-writer
soffice --help
eg:
soffice --headless --convert-to docx /www/asd.doc
docx 目標類型
/www/asd.doc 文件路徑
默認轉換完成的文件會存在 /root/asd.docx

eg:指定目錄
soffice --headless --convert-to docx --outdir /www /www/asd.doc
轉換完成的文件會存在 /www/asd.docx

原文鏈接https://blog.csdn.net/qq_46081276/article/deta
不同於python調用win32api只能在Windows使用

import subprocess

output = subprocess.check_output(["soffice","--headless","--invisible","--convert-to","docx","path/test.doc","--outdir","path/test.docx"])
with open(file_name, mode='wb') as f:
f.write(res.body)
import subprocess
subprocess.check_output(
["soffice", "--headless", "--invisible", "--convert-to", "docx", file_name, "--outdir",
"/tmp"])
x_path = f"/tmp/{file_name}x"
os.unlink(file_name)
os.unlink(x_path)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM