如何使用PYWIN32

问题描述 投票:0回答:1

import win32com.client #open win32 client in hidden mode word = win32com.client.Dispatch("Word.Application") word.Visible = False word.DisplayAlerts = False #tried setting this to False and 0 to suppress dialog. didn't work pdf_path = r"C:\path\to\pdf" doc_path = r"C:\path\to\docx" #open pdf doc with client pdf_doc = word.Documents.Open(pdf_path) #convert pdf to docx pdf_doc.SaveAs2(doc_path, FileFormat=16) #16 is the file format for docx. tried running this with pdf_doc.SaveAs. didn't work. pdf_doc.Close() #also tried running this as pdf_doc.Close(False). didn't work word.Quit()

dialog弹出窗口

改变
pdf_doc = word.Documents.Open(pdf_path)

to

pdf_doc = word.Documents.Open(pdf_path, False, False, False)
python windows pdf pywin32 file-conversion
1个回答
0
投票
为我解决了这个问题。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.