python doc转pdf
生活随笔
收集整理的這篇文章主要介紹了
python doc转pdf
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
doc轉pdf, 代碼如下:
from win32com import client import oswordhandle = client.Dispatch("Word.Application") wordhandle.Visible = 0 # 后臺運行,不顯示 wordhandle.DisplayAlerts = 0 #不警告 doc = wordhandle.Documents.Open(r'D:\1.docx') doc.SaveAs(r'D:\1.pdf', 17) # txt=4, html=10, docx=16, pdf=17 doc.Close() wordhandle.Quit()程序運行時,打開了要轉為pdf的Word文件,出現了以下的問題:
?在程序開始運行之前,關閉打開的word。
os.system('taskkill /f /im %s' % 'WINWORD.EXE') os.system('taskkill /f /im %s' % 'wps.exe')總結
以上是生活随笔為你收集整理的python doc转pdf的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 集成电路史上著名的十个人,有几个中国人?
- 下一篇: UNIX网络编程学习笔记(代码超详细解析