fix(docx): clean default python-docx metadata in docProps/core.xml
This commit is contained in:
1 parent
48e8370a46
commit
b0836f73a0
1 file changed
+13
@@ -138,6 +138,19 @@ def _execute_render_pipeline(source: dict, theme_name: str, job_id: str) -> str:
|
||||
output_docx_path = os.path.join(job_dir, "output.docx")
|
||||
try:
|
||||
docx_meta = renderer_docx.render_docx(source, theme_tokens, output_docx_path, figures_map, pdf_text=pdf_text)
|
||||
try:
|
||||
import zipfile, io
|
||||
with open(output_docx_path, "rb") as _f: _raw = _f.read()
|
||||
_zin = zipfile.ZipFile(io.BytesIO(_raw), "r"); _zbuf = io.BytesIO()
|
||||
_zout = zipfile.ZipFile(_zbuf, "w", compression=zipfile.ZIP_DEFLATED)
|
||||
for _item in _zin.infolist():
|
||||
_b = _zin.read(_item.filename)
|
||||
if _item.filename == "docProps/core.xml":
|
||||
_b = _b.replace(b"generated by python-docx", b"series-studio")
|
||||
_zout.writestr(_item, _b)
|
||||
_zin.close(); _zout.close()
|
||||
with open(output_docx_path, "wb") as _f: _f.write(_zbuf.getvalue())
|
||||
except Exception: pass
|
||||
journal_lines.append(f"DOCX rendu avec succès : {docx_meta['omath']} formules OMML, {docx_meta['draw']} figures, {docx_meta['dollar']} dollar(s)")
|
||||
except Exception as e:
|
||||
journal_lines.append(f"ERREUR rendu DOCX : {e}")
|
||||
|
||||
Reference in new issue
Block a user