I need some help. I am trying convert a docx to PDF, using FO format. Almost every docx is successfully converted, but when I include an image in the docx header, I get a NllPointerException. Example of the stacktrace:
- Code: Select all
java.lang.NullPointerException
at org.docx4j.openpackaging.parts.relationships.RelationshipsPart.getPart(RelationshipsPart.java:291)
at org.docx4j.model.images.AbstractWordXmlPicture.handleImageRel(AbstractWordXmlPicture.java:239)
at org.docx4j.model.images.WordXmlPictureE20.createWordXmlPictureFromE20(WordXmlPictureE20.java:267)
at org.docx4j.model.images.WordXmlPictureE20.createXslFoImgE20(WordXmlPictureE20.java:363)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(ExtensionHandlerJavaPackage.java:300)
at org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(ExtensionHandlerJavaPackage.java:440)
at org.apache.xalan.extensions.ExtensionsTable.extFunction(ExtensionsTable.java:222)
at org.apache.xalan.transformer.TransformerImpl.extFunction(TransformerImpl.java:475)
at org.apache.xpath.functions.FuncExtFunction.execute(FuncExtFunction.java:208)
at org.apache.xpath.XPath.execute(XPath.java:337)
at org.apache.xalan.templates.ElemCopyOf.execute(ElemCopyOf.java:134)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2402)
at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:128)
at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395)
at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:178)
at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395)
at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:178)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2402)
at org.apache.xalan.transformer.TransformerImpl.transformToRTF(TransformerImpl.java:1990)
at org.apache.xalan.transformer.TransformerImpl.transformToRTF(TransformerImpl.java:1912)
at org.apache.xalan.templates.ElemVariable.getValue(ElemVariable.java:312)
at org.apache.xalan.templates.ElemVariable.execute(ElemVariable.java:248)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2402)
at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:128)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2402)
at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:141)
at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395)
at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:178)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2402)
at org.apache.xalan.transformer.TransformerImpl.transformToRTF(TransformerImpl.java:1990)
at org.apache.xalan.transformer.TransformerImpl.transformToRTF(TransformerImpl.java:1912)
at org.apache.xalan.templates.ElemVariable.getValue(ElemVariable.java:312)
at org.apache.xalan.templates.ElemVariable.execute(ElemVariable.java:248)
at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395)
at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:178)
at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395)
at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:178)
at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395)
at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:178)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2402)
at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1376)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2402)
at org.apache.xalan.templates.ElemIf.execute(ElemIf.java:162)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2402)
at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1376)
at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395)
at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:178)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2402)
at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1376)
at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395)
at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:178)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2402)
at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2272)
at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1358)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:711)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1275)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1253)
at org.docx4j.XmlUtils.transform(XmlUtils.java:1041)
at org.docx4j.XmlUtils.transform(XmlUtils.java:932)
at org.docx4j.convert.out.common.AbstractXsltExporterDelegate.process(AbstractXsltExporterDelegate.java:66)
at org.docx4j.convert.out.common.AbstractWmlExporter.process(AbstractWmlExporter.java:63)
at org.docx4j.convert.out.common.AbstractWmlExporter.process(AbstractWmlExporter.java:32)
at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:79)
at org.docx4j.Docx4J.toFO(Docx4J.java:466)
at org.docx4j.convert.out.fo.FOPAreaTreeHelper.getAreaTreeViaFOP(FOPAreaTreeHelper.java:191)
at org.docx4j.convert.out.fo.LayoutMasterSetBuilder.fixExtents(LayoutMasterSetBuilder.java:136)
at org.docx4j.convert.out.fo.LayoutMasterSetBuilder.getLayoutMasterSetFragment(LayoutMasterSetBuilder.java:97)
at org.docx4j.convert.out.fo.XsltFOFunctions.getLayoutMasterSetFragment(XsltFOFunctions.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(ExtensionHandlerJavaPackage.java:343)
at org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(ExtensionHandlerJavaPackage.java:440)
at org.apache.xalan.extensions.ExtensionsTable.extFunction(ExtensionsTable.java:222)
at org.apache.xalan.transformer.TransformerImpl.extFunction(TransformerImpl.java:475)
at org.apache.xpath.functions.FuncExtFunction.execute(FuncExtFunction.java:208)
at org.apache.xpath.XPath.execute(XPath.java:337)
at org.apache.xalan.templates.ElemCopyOf.execute(ElemCopyOf.java:134)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2402)
at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1376)
at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395)
at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:178)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2402)
at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2272)
at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1358)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:711)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1275)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1253)
at org.docx4j.XmlUtils.transform(XmlUtils.java:1041)
at org.docx4j.XmlUtils.transform(XmlUtils.java:932)
at org.docx4j.convert.out.common.AbstractXsltExporterDelegate.process(AbstractXsltExporterDelegate.java:66)
at org.docx4j.convert.out.common.AbstractWmlExporter.process(AbstractWmlExporter.java:63)
at org.docx4j.convert.out.common.AbstractWmlExporter.process(AbstractWmlExporter.java:32)
at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:79)
at org.docx4j.Docx4J.toFO(Docx4J.java:466)
If I change the source docx file and include the image in the body instead of in the header, then the toFo method works fine. I face the same problem with footers with images. Is there a workaround in the source docx or it is a matter of code? Is it an already known issue?
[UPDATE]
I have noticed the problem occurs after a call of
- Code: Select all
org.docx4j.model.fields.merge.MailMerger.getConsolidatedResultCrude(wordMLPackage, valuesList, true);
Really thank you for the support.
Best,
Murilo