Truncate zip file before re-writing it. This prevents a misplaced zip file table of contents which can cause Microsoft word to go into recovery mode for a newly generated document.
This commit is contained in:
parent
671c7c78a7
commit
b3094f660a
@ -463,6 +463,8 @@ class DocxTemplate(object):
|
|||||||
DocxTemplate(docx_file).save(tmp_file)
|
DocxTemplate(docx_file).save(tmp_file)
|
||||||
tmp_file.seek(0)
|
tmp_file.seek(0)
|
||||||
docx_file.seek(0)
|
docx_file.seek(0)
|
||||||
|
docx_file.truncate()
|
||||||
|
docx_file.seek(0)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
tmp_file = '%s_docxtpl_before_replace_medias' % docx_file
|
tmp_file = '%s_docxtpl_before_replace_medias' % docx_file
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user