1
不知道爲什麼會發生這種情況,但下面的代碼確實會從我的文檔 中刪除頁眉和頁腳任何幫助表示讚賞?使用docxtpl時,頁眉和頁腳消失
from docxtpl import DocxTemplate
tpl=DocxTemplate('test_files/csa_template_tpl.docx')
sd = tpl.new_subdoc()
p = sd.add_paragraph('This 1st insert')
sd2 = tpl.new_subdoc()
p = sd2.add_paragraph('This 2nd insert')
context1 = {
'mysubdoc1' : sd,
'mysubdoc2' : sd2,
'cost' : '10,000',
'project_description': 'facade upgrade',
'site': 'Penrith',
'sp': 'xxxxxxxx',
'wo': '1',
'contract_manager': 'Andrew Mate',
'csa_no': '1',
}
tpl.render(context1)
tpl.save('test_files/csa_template.docx')