Hi,
My sample: sample.zip (7.9 KB)
Aspose version: Aspose.word NET 20.9
My code:
Document docfile;
using(var inStream = new FileStream(inputFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
docfile = new Document(inStream);
var docBuilder = new DocumentBuilder(docfile);
var shapes = docfile.GetChildNodes(NodeType.Shape, true).ToArray();
for(int i = 0; i < shapes.Length; i++)
{
using(var iconStream = new MemoryStream())
{
ShapeRenderer renderer = null;
var shape = (Shape)shapes[i];
try
{
renderer = shape.GetShapeRenderer();
renderer.Save(iconStream, new ImageSaveOptions(SaveFormat.Emf));
}
catch(Exception e)
{
string msg= e.ToString();
renderer = shape.GetShapeRenderer();
}
}
}
Problem is when calling GetShapeRenderer()
at the first time it will throw an exception, then catch it and call GetShapeRenderer()
again, it will work well.
Can you check and give feedback.
Thank you.