Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary .png files created by AbstractConversionImageHandler are not deleted after TOC generation #609

Open
jacksolovei opened this issue Mar 23, 2025 · 0 comments

Comments

@jacksolovei
Copy link

jacksolovei commented Mar 23, 2025

Hi,
I am using docx4j to convert data from a DOCX template to a DOCX file. The updateToc() method internally calls org.docx4j.model.images.AbstractConversionImageHandler, which creates temporary .png files for images in the document. After docx generation is complete, temporary .png files are not deleted and remain locked, file.delete() return false.

WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(tempResultInputStream); 
TocGenerator tocGenerator = new TocGenerator(wordMLPackage);
Docx4jProperties.setProperty("docx4j.toc.BookmarksIntegrity.remediate", true);
tocGenerator.updateToc(); в updateToc()

I have tried docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage.TempFiles.ForceGC=true and System.gc(), but this does not resolve the issue.

Is there a way to ensure these temporary files are deleted after use or maybe the AbstractConversionImageHandler can be configured to avoid creating these temporary files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant