<强>原理强>
使用python win32库调用单词底层vba,将词转成pdf
<>强安装pywin32
强>
pip安装pywin32
<强> python代码
强>
从win32com。客户端导入gencache 从win32com。客户进口常量,gencache def createPdf (wordPath pdfPath): ”“” 词转pdf :param wordPath:词文件路径 :param pdfPath:生成pdf文件路径 ”“” 词=gencache.EnsureDispatch (“Word.Application”) 医生=word.Documents。打开(wordPath只读=1) doc.ExportAsFixedFormat (pdfPath constants.wdExportFormatPDF, 项=constants.wdExportDocumentWithMarkup, CreateBookmarks=constants.wdExportCreateHeadingBookmarks) word.Quit (constants.wdDoNotSaveChanges)
工欲善其事,必先利其器!
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。