How to read/get Image from docx file and save to local drive
Posted: Sat Jan 03, 2015 10:21 pm
I have to read specific Image from .docx file and save on specific location.
but i'm unable to read it.
and getting "java.lang.IllegalArgumentException"
here is code...
here i'm getting bytes array but unable to use.
hope it's enough to understand.
any help.....
thanks
but i'm unable to read it.
and getting "java.lang.IllegalArgumentException"
here is code...
- Code: Select all
Drawing drw = (Drawing) XmlUtils.unwrap(drawingObjList.get(0));
if(drw != null)
{
List<Object> grp = ((Drawing) XmlUtils.unwrap(drw)).getAnchorOrInline();
if( grp != null)
{
Graphic grpdata = ((Inline) XmlUtils.unwrap(grp.get(0))).getGraphic();
byte[] imgBytes = BinaryPartAbstractImage.getImage(wProcessorPackage, grpdata);
RenderedImage renderImage = ImageIO.read(new ByteArrayInputStream(imgBytes));
ImageIO.write(renderImage, "jpg", new File("/Users/gwuser164/Desktop/Images/image.jpg"));
}
}
here i'm getting bytes array but unable to use.
hope it's enough to understand.
any help.....
thanks