Merge pull request #203 from edufresne/master
Fix need to "Recover document" after using replace_media and saving to file-like object
This commit is contained in:
commit
9f1cb53205
@ -456,8 +456,9 @@ class DocxTemplate(object):
|
|||||||
|
|
||||||
if hasattr(docx_file, 'read'):
|
if hasattr(docx_file, 'read'):
|
||||||
tmp_file = io.BytesIO()
|
tmp_file = io.BytesIO()
|
||||||
Document(docx_file).save(tmp_file)
|
DocxTemplate(docx_file).save(tmp_file)
|
||||||
tmp_file.seek(0)
|
tmp_file.seek(0)
|
||||||
|
docx_file.seek(0)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
tmp_file = '%s_docxtpl_before_replace_medias' % docx_file
|
tmp_file = '%s_docxtpl_before_replace_medias' % docx_file
|
||||||
|
|||||||
@ -32,4 +32,6 @@ tpl.render(context)
|
|||||||
file_obj = io.BytesIO()
|
file_obj = io.BytesIO()
|
||||||
tpl.save(file_obj)
|
tpl.save(file_obj)
|
||||||
file_obj.seek(0)
|
file_obj.seek(0)
|
||||||
DocxTemplate(file_obj).save(DEST_FILE2)
|
with open(DEST_FILE2, 'wb') as f:
|
||||||
|
f.write(file_obj.read())
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user