Version 0.2.1
This commit is contained in:
parent
686c519bf1
commit
4088bc4ab0
@ -1,3 +1,8 @@
|
||||
0.2.1 (2016-06-11)
|
||||
------------------
|
||||
- Fix bug where using subdocs is corrupting header and footer in generated docx
|
||||
Thanks to Denny Weinberg for his help.
|
||||
|
||||
0.2.0 (2016-03-17)
|
||||
------------------
|
||||
- Add Header and Footer support (Thanks to Denny Weinberg)
|
||||
|
||||
@ -5,7 +5,7 @@ Created : 2015-03-12
|
||||
@author: Eric Lapouyade
|
||||
'''
|
||||
|
||||
__version__ = '0.2.0'
|
||||
__version__ = '0.2.1'
|
||||
|
||||
from lxml import etree
|
||||
from docx import Document
|
||||
@ -127,6 +127,8 @@ class Subdoc(object):
|
||||
return getattr(self.subdocx, name)
|
||||
|
||||
def _get_xml(self):
|
||||
if self.subdocx._element.body.sectPr is not None:
|
||||
self.subdocx._element.body.remove(self.subdocx._element.body.sectPr)
|
||||
xml = re.sub(r'</?w:body[^>]*>','',etree.tostring(self.subdocx._element.body, encoding='unicode', pretty_print=False))
|
||||
return xml
|
||||
|
||||
|
||||
@ -9,10 +9,14 @@ from docxtpl import DocxTemplate
|
||||
|
||||
tpl=DocxTemplate('test_files/header_footer_tpl.docx')
|
||||
|
||||
sd = tpl.new_subdoc()
|
||||
p = sd.add_paragraph('This is a sub-document to check it does not break header and footer')
|
||||
|
||||
context = {
|
||||
'title' : 'Header and footer test',
|
||||
'company_name' : 'The World Wide company',
|
||||
'date' : '2016-03-17'
|
||||
'date' : '2016-03-17',
|
||||
'mysubdoc' : sd,
|
||||
}
|
||||
|
||||
tpl.render(context)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user