Retrieving Image using DrawingML


I insert a image in Docx file using MSWord. In code,previously the image is shown NodeType as ‘Shape’ object in aspose 4.2.0 jar.But now the image is shown NodeType as ‘DrawingML’ object in aspose 10.0 jar.How to retrieve the image information using this NodeType. Previously i used the following code,

if (NodeType.SHAPE)
    Shape shapeNode = ((Shape) this.node);
    ImageData image = shapeNode.getImageData();
    int img_type = image.getImageType();
    int width = (int) shapeNode.getWidth();
    int height = (int) shapeNode.getHeight();

How to get such information using aspose words for java version10.0 jar.

Thanks for your inquiry. Currently there are no public members to access the properties of a DrawingML node. We will be adding access to these properties sometime shortly. I have linked your request to the appropriate issue, you will be informed as soon as it’s resolved.
In the mean time you can still achieve what you are looking for by first saving your document in DOC format in memory, reloading it and using your code above. Please see the code below.

Document doc = new Document("C:\\Temp\\in2.docx");
// Convert DOCX to DOC to fix the problem.
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();, SaveFormat.DOC);
InputStream inputStream = new ByteArrayInputStream(byteStream.toByteArray());
// Create com.aspose.words.Document from InputStream.
doc = new Document(inputStream);
NodeCollection shapesColl = doc.getChildNodes(NodeType.SHAPE, true, false);
for (int i = 0; i <shapesColl.getCount(); i++)
    Shape shape = (Shape) shapesColl.get(i);
    // Idetntify shape with image
    if (shape.hasImage())

Best regards,

The issues you have found earlier (filed as WORDSNET-4791) have been fixed in this .NET update and in this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.