I am using the following code for rendering a image that is fetched from a remote url .
- Code: Select all
BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(bean.getDoc(), bytes);
Inline inline = imagePart.createImageInline( filenameHint, altText,
id1, id2);
MainDocumentPart objDocumentPart = bean.getDoc().getMainDocumentPart();
Relationship rel=objDocumentPart.addTargetPart(imagePart);
String wmlDrawing="<w:drawing style=\"position:absolute;margin-left:-7.2pt;margin-top:11.45pt;z-index:251623936;visibility:visible;mso-wrap-style:square;mso-width-percent:0;mso-height-percent:0;mso-wrap-distance-left:9pt;mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;mso-wrap-distance-bottom:0;mso-position-horizontal:absolute;mso-position-horizontal-relative:text;mso-position-vertical:absolute;mso-position-vertical-relative:text;mso-width-percent:0;mso-height-percent:0;mso-width-relative:page;mso-height-relative:page;v-text-anchor:top\" xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\"><wp:anchor distT=\"0\" distB=\"0\" distL=\"114300\" distR=\"114300\" simplePos=\"0\" behindDoc=\"0\" locked=\"0\" layoutInCell=\"1\" allowOverlap=\"1\" wp14:anchorId=\"5F157C69\" wp14:editId=\"5652B3BE\"><wp:simplePos x=\"0\" y=\"0\"/><wp:positionH relativeFrom=\"column\"><wp:posOffset>-372110</wp:posOffset></wp:positionH><wp:positionV relativeFrom=\"page\"><wp:posOffset>952500</wp:posOffset></wp:positionV><wp:extent cx=\""+iWidth+"\" cy=\""+iheight+"\" /><wp:effectExtent l=\"0\" t=\"0\" r=\"0\" b=\"9525\"/><wp:wrapNone/><wp:docPr id=\"203\" name=\"Picture 203\" descr=\"Logo\"/><wp:cNvGraphicFramePr><a:graphicFrameLocks xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" noChangeAspect=\"1\"/></wp:cNvGraphicFramePr><a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\"><pic:pic xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\"><pic:nvPicPr><pic:cNvPr id=\"0\" name=\"Picture 203\" descr=\"Logo\"/><pic:cNvPicPr><a:picLocks noChangeAspect=\"1\" noChangeArrowheads=\"1\"/></pic:cNvPicPr></pic:nvPicPr><pic:blipFill><a:blip r:embed=\""+rel.getId()+"\"><a:extLst><a:ext uri=\"{28A0092B-C50C-407E-A947-70E740481C1C}\"><a14:useLocalDpi xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" val=\"0\"/></a:ext></a:extLst></a:blip><a:srcRect/><a:stretch><a:fillRect/></a:stretch></pic:blipFill><pic:spPr bwMode=\"auto\"><a:xfrm><a:off x=\"0\" y=\"0\"/><a:ext cx=\""+iWidth+"\" cy=\""+iheight+"\"/></a:xfrm><a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom><a:noFill/><a:ln><a:noFill/></a:ln></pic:spPr></pic:pic></a:graphicData></a:graphic><wp14:sizeRelH relativeFrom=\"page\"><wp14:pctWidth>0</wp14:pctWidth></wp14:sizeRelH><wp14:sizeRelV relativeFrom=\"page\"><wp14:pctHeight>0</wp14:pctHeight></wp14:sizeRelV></wp:anchor></w:drawing>";
Drawing objDrawing = (Drawing)XmlUtils.unmarshalString(wmlDrawing,Context.jc,Drawing.class);
bean.getCurrentParg().getContent().add(objDrawing);;
When I execute my application in my local system(windows 2007 ), it is generating/rendering the image properly with out any error.
But I execute the application in my client machine (Linux box) The image is not rendering properly and getting the following error.
-
- Code: Select all
[ERROR] : unexpected element (uri:"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing", local:"sizeRelH"). Expect
- continuing (with possible element/attribute loss)
- [ERROR] : unexpected element (uri:"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing", local:"sizeRelV"). Expect
- continuing (with possible element/attribute loss)
- found a:graphic
- found CTBlip
Currently I am using "docx4j-nightly-20120204.jar" file.
Please correct me where I am doing the mistake.
Thanks & Regards,
B.V.Suresh Babu.