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?