[Using Aspose.Words.dll 13.5.0.0]
Is it possible to get the native Shapes generated from Word as images via Aspose?
Let me explain what I'm trying to do...
I have a dummy document with a Flowchart: Document shape in it. When opening this document programatically with Aspose, then saving it to disk as HTML named "Dummy.html", I get an image associated with that file saved on disk as "Dummy.001.png" and the resulting html looks fine. So I know your code is able to read that shape and translate it to an image. I want to be able to get that raw image too in the code behind while processing the document.
I can successfully intercept the Node's image for those attached to the document, but not the raw Word Shapes. To do this so far I have:
//node is just some node off a random paragraph
if (node.NodeType == NodeType.Shape)//This returns true
{
Aspose.Words.Drawing.Shape shape = (Aspose.Words.Drawing.Shape)node; // I can also cast this as a ShapeBase instead
if (shape.HasImage)//This returns false for Word native shapes!
{
//I do this for embedded images, works great!
byte[] inputBytes = shape.ImageData.ImageBytes;
MemoryStream memoryStream = new MemoryStream(inputBytes);
System.Drawing.Image img = System.Drawing.Image.FromStream(memoryStream);
//Etc etc....
}
else if (shape.CanHaveImage)//This returns true. What governs what this returns?
{
//Execute my code here?
}
}
....
As I said this works just fine for images actually uploaded into the document that are non-native. Hence my use of the shape.HasImage. See the code in red for how I use that.
However, I want to be able to grab the native Shapes that Word uses in the same manner. I don't care if its a byte array, a memory stream, or Image, I need some way of getting that raw image back.
I can see limited information about the shape object if I cast the node differently, (ShapeBase)(node).ShapeType, this gets me the related shape type from Word (FlowChartDocument - As seen in your documentation http://www.aspose.com/docs/display/wordsnet/ShapeType+Enumeration) but from all points I've tried to look at, I'm unable to get any kind of image data. I can even see the text inside the Shape "Hello World"! But from everything I've tried, I cannot get that Shape.