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

Free Support Forum - aspose.com

Image missing when a word doc is extracted using Aspose.Word (Java)

Team,
I tried to extract text and image from a Word doc using the Aspose.word.
Image was missing from the extracted output.
Is there a way that i can fix this?
Thanks
Nimalan

Hi
Thanks for your inquiry. Could you please attach your document for testing and provide me your code? I will investigate the issue and provide you more information.
Best regards.

Please see attached document.

  1. code.txt
  2. SampleDocument.doc

As i said earlier we are using the Aspose.Word (java).

Let me know if you need more information.

Thanks,
Nimalan

Hi
Thank you for additional information. Your code extracts text only. If you need to extract images form the document your can use the following code:

Document doc = new Document("C:\\Temp\\SampleDocument.doc");
// Get collection of shapes
NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
int i = 0;
for (Object node : shapes)
{
    Shape shape = (Shape)node;
    if (shape.hasImage())
    {
        shape.getImageData().save(String.format("C:\\Temp\\img_%1$2s.jpg", i));
        i++;
    }
}

Hope this helps.
Best regards.