问题修复
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
import traceback
|
||||
|
||||
import pythoncom
|
||||
from PySide6.QtCore import QObject, Signal
|
||||
from win32com import client
|
||||
|
||||
@@ -52,10 +53,13 @@ class DTGWorker(QObject):
|
||||
if os.path.exists(pdf_file):
|
||||
os.remove(pdf_file)
|
||||
|
||||
word = client.Dispatch("Word.Application")
|
||||
# https://stackoverflow.com/questions/71292585/python-docx2pdf-attributeerror-open-saveas
|
||||
word = client.Dispatch("Word.Application", pythoncom.CoInitialize())
|
||||
try:
|
||||
doc = word.Documents.Open(word_file)
|
||||
doc.SaveAs(pdf_file, 17)
|
||||
doc.Close()
|
||||
finally:
|
||||
word.Quit()
|
||||
|
||||
os.remove(word_file)
|
||||
|
||||
Reference in New Issue
Block a user