Extracting Image content from DrawingML

Hello,
I need to extract the byte content of nodes with the NodeType DrawingML. According to the documentation the drawingml should expose a getshaperenderer method. So does https://reference.aspose.com/words/net/aspose.words.drawing/shape/. It even lists an ImageData property says “In this version of Aspose.Words, DrawingML nodes do not provide public methods and properties to create or modify a DrawingML object”
Well, I don’t want to do anything… I just want the byte content. How can I get it?
Thanks in advance

Hi Anja,

Thanks for your inquiry. Please try using the following code snippet to extract bytes from DrawingML images:

Document doc = new Document(@"C:\Temp\in.docx");
DrawingML dml = (DrawingML) doc.GetChildNodes(NodeType.DrawingML, true)[0];
ShapeRenderer renderer = dml.GetShapeRenderer();
MemoryStream stream = new MemoryStream();
renderer.Save(stream, new ImageSaveOptions(SaveFormat.Png));
byte[] bytes = stream.GetBuffer();

I hope, this helps.

Best Regards,