使用 docxtpl 时页眉和页脚消失

Header and Footer disappear when using 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')

问题已解决,库文档提到与新word文档版本的兼容性问题,我保存时恢复为"Maintain compatibility with previous versions of word"。