支持两种学生名单
This commit is contained in:
@@ -56,23 +56,23 @@ class DTGWorker(QObject):
|
||||
|
||||
if os.path.exists(pdf_file):
|
||||
os.remove(pdf_file)
|
||||
|
||||
pythoncom.CoInitialize()
|
||||
# https://stackoverflow.com/questions/71292585/python-docx2pdf-attributeerror-open-saveas
|
||||
word = client.Dispatch("Word.Application", pythoncom.CoInitialize())
|
||||
word = client.Dispatch("Word.Application")
|
||||
doc = word.Documents.Open(word_file)
|
||||
try:
|
||||
doc = word.Documents.Open(word_file)
|
||||
doc.SaveAs(pdf_file, 17)
|
||||
doc.Close()
|
||||
os.remove(word_file)
|
||||
os.startfile(pdf_file)
|
||||
except Exception as e:
|
||||
raise Exception("PDF转换失败,但Word文档已生成") from e
|
||||
finally:
|
||||
doc.Close()
|
||||
word.Quit()
|
||||
elif self.output_type == 'word':
|
||||
os.startfile(word_file)
|
||||
except Exception as e:
|
||||
self.error.emit("😢 不好出错了", e)
|
||||
except Exception:
|
||||
self.error.emit("😢 不好出错了", traceback.format_exc())
|
||||
self.progress[int].emit(-1)
|
||||
finally:
|
||||
self.finished.emit()
|
||||
|
||||
Reference in New Issue
Block a user