首页 > 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

网络收集

更多相关:

  • important_dic = {'预付卡'}weight = 3 #可以修改,也可以再字典里添加权值k=0for word in set(sent): if word in important_dic: k = weight else: k = 0 if wor...