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

Free Support Forum - aspose.com

Extracting Inline images from Word document


The last image at the end of document is also an inline image. As shown in the following screenshot:

All three images are part of the same Paragraph. So, this is expected behavior and you need to modify the source document to get the desired results.

I again find some other images other than inline images are extracted help please. Input is ManuscriptCDTe QDs Final211.zip (1.4 MB)
and the output extracted is ManuscriptCDTe QDs Final211 -shape.zip (202.7 KB)
Help please. can you please share the code.


I am afraid, the big figure on page 4 of “ManuscriptCDTe QDs Final211.doc” is also inline and you can verify it inside Document.xml file. If we can help you with anything else, please feel free to ask.


The image 1 in this input document is not retrieved it is extracted as bit 0 kb. Kindly suggest how to get the correct image. The input I used is Anchored_Images.zip (2.6 MB)
and the interim generated is Anchored_Images_Interim (2).zip (13.4 KB)
and the output file is Anchored_Images (2).zip (2.6 MB) Kindly help please


Please try using the following code and see these output documents output.zip (2.6 MB).

Document doc = new Document("D:\\temp\\Anchored_Images (2)\\Anchored_Images.docx");
DocumentBuilder builder = new DocumentBuilder(doc);

int i = 1;
for (Shape shape : (Iterable<Shape>) doc.getChildNodes(NodeType.SHAPE, true)) {

    if (shape.getParentParagraph() == null ||
            shape.getParentParagraph().getChildNodes().getCount() == 1 ||
            shape.getAncestor(NodeType.TABLE) != null ||
            shape.getShapeType() == ShapeType.TEXT_BOX) {

    } else {
        Document newDoc = (Document) doc.deepClone(false);

        Shape importedShape = (Shape) newDoc.importNode(shape, true);


        builder.write(" <Inline-Img>Inline-Img" + i + "</Inline-Img> ");


        newDoc.save("D:\\temp\\Anchored_Images (2)\\shape_" + i + ".docx");

doc.save("D:\\temp\\Anchored_Images (2)\\out.docx");