Reputation: 2433
not sure why this is happening, but the below code does remove the header and footer from my document any help appreciated?
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')
Upvotes: 1
Views: 1102
Reputation: 2433
Problem solved, the library documentation mentions compatibility issues with new word document version, i reverted to "Maintain compatibility with previous versions of word" when saving.
Upvotes: 1