v0.7.0
This commit is contained in:
parent
dc571cfaf7
commit
888dd085f6
@ -1,3 +1,7 @@
|
||||
0.7.0 (2020-04-09)
|
||||
-------------------
|
||||
- Add replace_zipname() method to replace Excel and PowerPoint embedded files
|
||||
|
||||
0.6.4 (2020-04-06)
|
||||
-------------------
|
||||
- Add the possibility to add RichText to a Richtext
|
||||
|
||||
@ -7,12 +7,11 @@ Created : 2015-03-12
|
||||
import functools
|
||||
import io
|
||||
|
||||
__version__ = '0.6.9'
|
||||
__version__ = '0.7.0'
|
||||
|
||||
from lxml import etree
|
||||
from docx import Document
|
||||
from docx.opc.oxml import serialize_part_xml, parse_xml
|
||||
from docx.opc.part import XmlPart
|
||||
import docx.oxml.ns
|
||||
from docx.opc.constants import RELATIONSHIP_TYPE as REL_TYPE
|
||||
from jinja2 import Environment, Template, meta
|
||||
@ -238,8 +237,8 @@ class DocxTemplate(object):
|
||||
|
||||
def get_headers_footers_xml(self, uri):
|
||||
for relKey, val in self.docx._part._rels.items():
|
||||
if (val.reltype == uri) and (val.target_part.blob):
|
||||
yield relKey, self.xml_to_string(parse_xml(val.target_part.blob))
|
||||
if (val.reltype == uri) and (val._target._blob):
|
||||
yield relKey, self.xml_to_string(parse_xml(val._target._blob))
|
||||
|
||||
def get_headers_footers_encoding(self,xml):
|
||||
m = re.match(r'<\?xml[^\?]+\bencoding="([^"]+)"',xml,re.I)
|
||||
@ -255,8 +254,7 @@ class DocxTemplate(object):
|
||||
yield relKey, xml.encode(encoding)
|
||||
|
||||
def map_headers_footers_xml(self, relKey, xml):
|
||||
part = self.docx._part._rels[relKey].target_part
|
||||
self.docx._part._rels[relKey]._target = XmlPart.load(part.partname, part.content_type, xml, part.package)
|
||||
self.docx._part._rels[relKey]._target._blob = xml
|
||||
|
||||
def render(self, context, jinja_env=None, autoescape=False):
|
||||
if autoescape:
|
||||
@ -512,6 +510,9 @@ class DocxTemplate(object):
|
||||
elif ( item.filename.startswith('word/media/') and
|
||||
item.CRC in self.crc_to_new_media ):
|
||||
zout.writestr(item, self.crc_to_new_media[item.CRC])
|
||||
elif ( item.filename.startswith('word/embeddings/') and
|
||||
item.CRC in self.crc_to_new_embedded):
|
||||
zout.writestr(item, self.crc_to_new_embedded[item.CRC])
|
||||
else:
|
||||
zout.writestr(item, buf)
|
||||
|
||||
|
||||
2
setup.py
2
setup.py
@ -59,7 +59,7 @@ setup(name='docxtpl',
|
||||
license='LGPL 2.1',
|
||||
packages=['docxtpl'],
|
||||
install_requires=['six',
|
||||
'python-docx',
|
||||
'python-docx<=0.8.7', # newer docx package breaks header/footer management in docxtpl
|
||||
'jinja2',
|
||||
'lxml'],
|
||||
extras_require={'docs': ['Sphinx', 'sphinxcontrib-napoleon']},
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user