org.apache.poi.xwpf.converter.core.XWPFConverterException union value '0000'

1.9k views Asked by At

I convert a .docx document with apache poi to .pdf, the word file is generated correctly with docx4j, but when i tried pass to PDF apache poi throws an exception:

org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException: union value '00000' does not match any members of 'ST_HexColor in namespace http://schemas.openxmlformats.org/wordprocessingml/2006/main'
org.apache.xmlbeans.impl.values.XmlUnionImpl.set_text(XmlUnionImpl.java:154)
org.apache.xmlbeans.impl.values.XmlObjectBase.update_from_wscanon_text(XmlObjectBase.java:1166)
org.apache.xmlbeans.impl.values.XmlObjectBase.check_dated(XmlObjectBase.java:1305)
org.apache.xmlbeans.impl.values.XmlObjectBase.isNil(XmlObjectBase.java:661)
org.apache.xmlbeans.impl.values.XmlObjectBase.java_value(XmlObjectBase.java:2939)
org.apache.xmlbeans.impl.values.XmlObjectBase.getObjectValue(XmlObjectBase.java:1669)
org.openxmlformats.schemas.wordprocessingml.x2006.main.impl.CTColorImpl.getVal(Unknown Source)
org.apache.poi.xwpf.converter.core.utils.ColorHelper.getColor(ColorHelper.java:65)
org.apache.poi.xwpf.converter.core.styles.run.RunFontColorValueProvider.getValue(RunFontColorValueProvider.java:42)
org.apache.poi.xwpf.converter.core.styles.run.RunFontColorValueProvider.getValue(RunFontColorValueProvider.java:33)
org.apache.poi.xwpf.converter.core.styles.run.AbstractRunValueProvider.getValueFromElement(AbstractRunValueProvider.java:76)
org.apache.poi.xwpf.converter.core.styles.run.AbstractRunValueProvider.getValueFromElement(AbstractRunValueProvider.java:44)
org.apache.poi.xwpf.converter.core.styles.AbstractValueProvider.internalGetValue(AbstractValueProvider.java:50)
org.apache.poi.xwpf.converter.core.styles.AbstractValueProvider.getValue(AbstractValueProvider.java:41)
org.apache.poi.xwpf.converter.core.styles.XWPFStylesDocument.getFontColor(XWPFStylesDocument.java:670)
org.apache.poi.xwpf.converter.pdf.internal.PdfMapper.visitRun(PdfMapper.java:464)
org.apache.poi.xwpf.converter.pdf.internal.PdfMapper.visitRun(PdfMapper.java:111)
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.visitRuns(XWPFDocumentVisitor.java:616)
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.visitParagraphBody(XWPFDocumentVisitor.java:441)
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.visitParagraph(XWPFDocumentVisitor.java:332)
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.visitBodyElements(XWPFDocumentVisitor.java:247)
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.start(XWPFDocumentVisitor.java:199)
org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:56)
org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:38)
org.apache.poi.xwpf.converter.core.AbstractXWPFConverter.convert(AbstractXWPFConverter.java:45)
net.solsersistem.utils.pdf.PDFUtils.convertDocxToPDF(PDFUtils.java:24)
net.solser.admc.service.purchasingflow.PurchasingRequisitionService.sendFileToDownload(PurchasingRequisitionService.java:1173)
net.solser.admc.service.purchasingflow.PurchasingRequisitionService.sendFileToDownloadAndDeleteFile(PurchasingRequisitionService.java:1185)
net.solser.admc.service.purchasingflow.PurchasingRequisitionService.downloadDraftContract(PurchasingRequisitionService.java:347)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
net.solser.admc.filter.RequestSecurityFilter.doFilter(RequestSecurityFilter.java:48)
net.solser.filter.compress.GzipFilter.doFilter(GzipFilter.java:35)

this exception is caused by .docx xml, not recognize the color tag. here an example:

<w:r>
     <w:rPr>
                <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
                <w:b w:val="false"/>
                <w:color w:val="00000"/>
                <w:sz w:val="21"/>
                <w:szCs w:val="21"/>
                <w:u w:val="none"/>
            </w:rPr>
            <w:t xml:space="preserve">313421</w:t>
        </w:r>

when i remove w:color w:val="00000" tag the pdf is generated. the same situation when i try convert PDF with docx4j.

Any idea.

Tanks

0

There are 0 answers