Hi Jason,
I am using the docx4j-2-2-2 distribution and I encountered a problem trying to open, manipolate and saving again a docx file.
I have figured out the problem: this word file has an header with an image but somehow is not reconigned as the same image in all the pages. This means that in the docx I have different pointers to apparently different file images but at the end they converge to the same real file image.
During the saving process I receive an exception because it's trying to save the file image more than once.
I think it would be enough if your code would just skip in case of replication instead than throws an exception blocking the saving procedure.
I would be grateful to you if you could provide a distribution with just this bug fixed. I would do it personally but for licence issues I cannot used a library built on myself.
Thank you very much in advance.
This is the exception:
org.docx4j.openpackaging.exceptions.Docx4JException: Failed to add parts from relationships
at org.docx4j.openpackaging.io.SaveToZipFile.addPartsFromRelationships(SaveToZipFile.java:319)
at org.docx4j.openpackaging.io.SaveToZipFile.save(SaveToZipFile.java:130)
at org.docx4j.openpackaging.io.SaveToZipFile.save(SaveToZipFile.java:93)
at esa.esoc.ops.hsc.reporting.core.Traverse.createReport(Traverse.java:147)
at esa.esoc.ops.hsc.reporting.core.DOC4JComponent.createReport(DOC4JComponent.java:58)
at TestReporting.main(TestReporting.java:91)
Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Failed to add parts from relationships
at org.docx4j.openpackaging.io.SaveToZipFile.addPartsFromRelationships(SaveToZipFile.java:319)
at org.docx4j.openpackaging.io.SaveToZipFile.savePart(SaveToZipFile.java:360)
at org.docx4j.openpackaging.io.SaveToZipFile.addPartsFromRelationships(SaveToZipFile.java:314)
... 5 more
Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Failed to add parts from relationships
at org.docx4j.openpackaging.io.SaveToZipFile.addPartsFromRelationships(SaveToZipFile.java:319)
at org.docx4j.openpackaging.io.SaveToZipFile.savePart(SaveToZipFile.java:360)
at org.docx4j.openpackaging.io.SaveToZipFile.addPartsFromRelationships(SaveToZipFile.java:314)
... 7 more
Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Failed to put binary part
at org.docx4j.openpackaging.io.SaveToZipFile.saveRawBinaryPart(SaveToZipFile.java:396)
at org.docx4j.openpackaging.io.SaveToZipFile.savePart(SaveToZipFile.java:342)
at org.docx4j.openpackaging.io.SaveToZipFile.addPartsFromRelationships(SaveToZipFile.java:314)
... 9 more
Caused by: java.util.zip.ZipException: duplicate entry: word/media/image5.jpeg
at java.util.zip.ZipOutputStream.putNextEntry(Unknown Source)
at org.docx4j.openpackaging.io.SaveToZipFile.saveRawBinaryPart(SaveToZipFile.java:375)
... 11 more