修改答辩题目页面大小
This commit is contained in:
@@ -2,7 +2,7 @@ import pathlib
|
|||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
from docx import Document
|
from docx import Document
|
||||||
from docx.shared import Cm
|
from docx.shared import Cm, Mm
|
||||||
|
|
||||||
from module.schema import Course, Student
|
from module.schema import Course, Student
|
||||||
|
|
||||||
@@ -14,6 +14,8 @@ class DocPaper:
|
|||||||
self._filename = filename
|
self._filename = filename
|
||||||
|
|
||||||
section = self._doc.sections[0]
|
section = self._doc.sections[0]
|
||||||
|
section.page_width = Mm(210)
|
||||||
|
section.page_height = Mm(297)
|
||||||
section.top_margin = Cm(2)
|
section.top_margin = Cm(2)
|
||||||
section.bottom_margin = Cm(2)
|
section.bottom_margin = Cm(2)
|
||||||
section.left_margin = Cm(2)
|
section.left_margin = Cm(2)
|
||||||
|
|||||||
@@ -62,12 +62,14 @@ class DTGWorker(QObject):
|
|||||||
doc = word.Documents.Open(word_file)
|
doc = word.Documents.Open(word_file)
|
||||||
try:
|
try:
|
||||||
doc.SaveAs(pdf_file, 17)
|
doc.SaveAs(pdf_file, 17)
|
||||||
|
doc.Close()
|
||||||
os.remove(word_file)
|
os.remove(word_file)
|
||||||
os.startfile(pdf_file)
|
os.startfile(pdf_file)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise Exception("PDF转换失败,但Word文档已生成") from e
|
|
||||||
finally:
|
|
||||||
doc.Close()
|
doc.Close()
|
||||||
|
os.startfile(word_file)
|
||||||
|
raise Exception("PDF转换失败,但Word文档已生成,已打开Word文档") from e
|
||||||
|
finally:
|
||||||
word.Quit()
|
word.Quit()
|
||||||
elif self.output_type == 'word':
|
elif self.output_type == 'word':
|
||||||
os.startfile(word_file)
|
os.startfile(word_file)
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user