Can not save while the header contain TIFF image
Posted: Tue Feb 21, 2012 4:25 pm
Hi, I got below exceptions when saving the docx file.
Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Couldn't load file from C:\temp\1.docx
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:180)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:172)
at com.cliu.test.Docx4j.main(Docx4j.java:16)
Caused by: java.io.FileNotFoundException: C:\temp\1.docx (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:177)
... 2 more
I designed a docx with headers, and each header contain a TIFF image(picture.tif). Then loaded the docx with docx4j, saved to docx file back with no processing, got the exception.
I reviewed the source code and find the problem in org.docx4j.openpackaging.contenttype.ContentTypeManager class:
if (!partName.toLowerCase().endsWith("." + ContentTypes.EXTENSION_TIFF)) {
partName = partName + "." + ContentTypes.EXTENSION_TIFF;
}
The "tif" and "tiff" suffix for TIFF image are all legal, but just support the "tiff". If I change the code to this, the issue will be ok:
if (!partName.toLowerCase().endsWith("." + ContentTypes.EXTENSION_TIFF) && !partName.toLowerCase().endsWith(".tif")) {
partName = partName + "." + ContentTypes.EXTENSION_TIFF;
}
My project need this change to support TIFF image, how could I submit or anybody can help me to submit the change?
Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Couldn't load file from C:\temp\1.docx
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:180)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:172)
at com.cliu.test.Docx4j.main(Docx4j.java:16)
Caused by: java.io.FileNotFoundException: C:\temp\1.docx (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:177)
... 2 more
I designed a docx with headers, and each header contain a TIFF image(picture.tif). Then loaded the docx with docx4j, saved to docx file back with no processing, got the exception.
I reviewed the source code and find the problem in org.docx4j.openpackaging.contenttype.ContentTypeManager class:
if (!partName.toLowerCase().endsWith("." + ContentTypes.EXTENSION_TIFF)) {
partName = partName + "." + ContentTypes.EXTENSION_TIFF;
}
The "tif" and "tiff" suffix for TIFF image are all legal, but just support the "tiff". If I change the code to this, the issue will be ok:
if (!partName.toLowerCase().endsWith("." + ContentTypes.EXTENSION_TIFF) && !partName.toLowerCase().endsWith(".tif")) {
partName = partName + "." + ContentTypes.EXTENSION_TIFF;
}
My project need this change to support TIFF image, how could I submit or anybody can help me to submit the change?