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.

Document doc = new Document(MYDir +  "Image.SampleImages.doc");

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);