python中 doc_python中doc转pdf
生活随笔
收集整理的這篇文章主要介紹了
python中 doc_python中doc转pdf
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
pip install pywin32
from win32com.client import gencache
from win32com.client import constants, gencache
def doctupdf(wordPath, pdfPath):
"""
word轉pdf
:param wordPath: word文件路徑
:param pdfPath: 生成pdf文件路徑
"""
word = gencache.EnsureDispatch('Word.Application')
doc = word.Documents.Open(wordPath, ReadOnly=1)
doc.ExportAsFixedFormat(pdfPath,
constants.wdExportFormatPDF,
Item=constants.wdExportDocumentWithMarkup,
CreateBookmarks=constants.wdExportCreateHeadingBookmarks)
word.Quit(constants.wdDoNotSaveChanges)
用python的win32庫,調用word底層vba將doc轉成pdf
網絡收集
總結
以上是生活随笔為你收集整理的python中 doc_python中doc转pdf的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ml不是内部或外部命令_美国飞机制造商波
- 下一篇: python3 ocr_OCR识别-py