We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Unable to extract images from docx and odt


I'm able to extract images from .doc document but can't retrieve from .odt & .docx.

I'm using the same code of Aspose words to retrieve the images from .doc, .odt and .docx.

for (Shape shape : (Iterable) doc.getChildNodes(NodeType.SHAPE, true)){

if(shape.getImageData() != null){

//code to retrieve the images


} Logger statement....

for .docx and .odt, after the for statement, the logger statement gets executed whereas for .doc, if statement is executed.

Please advise.

.odt is working fine but not the .docx


Pramod Talekar

Hi Pramod,

Thanks for your inquiry. Please use the latest version of Aspose.Words for Java. If you still face problem, please share your document for investigation purposes.

<span lang=“EN-GB” style=“font-size:10.0pt;font-family:“Courier New”;color:#2B91AF;mso-font-kerning:
0pt;mso-no-proof:yes”>Document<span lang=“EN-GB” style=“font-size:10.0pt;
font-family:“Courier New”;mso-font-kerning:0pt;mso-no-proof:yes”> doc = new Document(MYDir

  • “Image.SampleImages.doc”);<o:p></o:p>

NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);

int imageIndex = 0;

for (Shape shape : (Iterable<Shape>) shapes)


if (shape.hasImage())


String imageFileName = java.text.MessageFormat.format(

"Image.ExportImages.{0} Out{1}", imageIndex, FileFormatUtil.imageTypeToExtension(shape.getImageData().getImageType()));

shape.getImageData().save(MYDir + imageFileName);