I want to open several docx and some of them have been edited in several Word versions over the passt few years. As it seems, Word has saved an invalid state sometimes. Word itself can handle this, but docx4j 8.3.8 is throwing an exception, like this one:
- Code: Select all
org.docx4j.openpackaging.exceptions.Docx4JException: For source /word/header1.xml, cannot find part word/NULL from rel rId1=NULL
at org.docx4j.openpackaging.io3.Load3.getRawPart(Load3.java:626) ~[docx4j-core-8.3.8.jar:na]
at org.docx4j.openpackaging.io3.Load3.getPart(Load3.java:372) ~[docx4j-core-8.3.8.jar:na]
at org.docx4j.openpackaging.io3.Load3.addPartsFromRelationships(Load3.java:278) ~[docx4j-core-8.3.8.jar:na]
at org.docx4j.openpackaging.io3.Load3.getPart(Load3.java:400) ~[docx4j-core-8.3.8.jar:na]
at org.docx4j.openpackaging.io3.Load3.addPartsFromRelationships(Load3.java:278) ~[docx4j-core-8.3.8.jar:na]
at org.docx4j.openpackaging.io3.Load3.getPart(Load3.java:400) ~[docx4j-core-8.3.8.jar:na]
at org.docx4j.openpackaging.io3.Load3.addPartsFromRelationships(Load3.java:278) ~[docx4j-core-8.3.8.jar:na]
at org.docx4j.openpackaging.io3.Load3.get(Load3.java:196) ~[docx4j-core-8.3.8.jar:na]
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:572) ~[docx4j-core-8.3.8.jar:na]
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:421) ~[docx4j-core-8.3.8.jar:na]
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:387) ~[docx4j-core-8.3.8.jar:na]
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:352) ~[docx4j-core-8.3.8.jar:na]
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:182) ~[docx4j-core-8.3.8.jar:na]
I uploaded word_null.docx with an example. In the header of page 2 is an image which has lost its imagedata as it seems. Word itself is displaying the missing data as in the uploaded screenshot.
Is it possible to handle this exception in docx4j internally, so that the loading of this file is still possible? This robust approach would be a better behaviour in my use cases.
Kind regards,
Christian.