Free Support Forum - aspose.com

Extracting Image content from DrawingML

Hello,

I need to extract the byte content of nodes with the NodeType DrawingML. According to http://www.aspose.com/docs/display/wordsnet/Rendering+a+DrawingML+Image the DrawingML should expose a GetShapeRenderer method. So does http://www.aspose.com/docs/display/wordsnet/DrawingML+Members. It even lists an ImageData property. http://www.aspose.com/docs/display/wordsnet/DrawingML+Class 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,