When I run this code:
- Code: Select all
WordprocessingMLPackage wordprocessingMLPackage = WordprocessingMLPackage.load(new File("c:\\document.docx"));
System.out.println(XmlUtils.marshaltoString(wordprocessingMLPackage.getMainDocumentPart().getJaxbElement(), true, true));
throw an exception
- Code: Select all
INFO [org.docx4j.utils.XPathFactoryUtil:22] - xpath implementation: org.apache.xpath.jaxp.XPathFactoryImpl
INFO [org.docx4j.openpackaging.io3.Load3:180] - package read; elapsed time: 4635 ms
INFO [org.docx4j.openpackaging.parts.JaxbXmlPart:129] - Lazily unmarshalling /word/document.xml
INFO [org.docx4j.openpackaging.parts.JaxbXmlPartXPathAware:299] - For org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart, unmarshall via binder
java.lang.NumberFormatException: For input string: "10206.0"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:458)
at java.math.BigInteger.<init>(BigInteger.java:316)
at java.math.BigInteger.<init>(BigInteger.java:451)
at com.sun.xml.bind.DatatypeConverterImpl._parseInteger(DatatypeConverterImpl.java:88)
I view the document.xml and really somewhere there is
- Code: Select all
... <w:tblW w:w="10206.0" w:type="dxa"/> ...
I can conclude that the cause of error is the 10206.0 value of <w:tblW w:w and the docx4j expect an integer instead of a bigdecimal
I tested with docx4j-3.0.1 bu problem is the same
Note: the document.docx was created in the Google Docs and downloaded as docx
Attached is the document.docx
Many Thanks
Regards
Sérgio