We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Identify chart shapes in a Word document

Is the Aspose Words API able to distinguish charts from other shapes in a Word document? Word interop provides a way to detect chart shapes via the InLineShape.HasChart property, but we are unable to find corresponding functionality in Aspose Words.
Please advise.

Hi Lloyd,
A new feature request to support this feature has been logged into our issue tracking system as WORDSNET-11858. We will keep you updated on this issue in this thread.
Best Regards,

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

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

Is it possible to convert charts to images within the document?

Please advise.

Hi Lloyd,

Thanks for your inquiry. You can use the following code to convert Chart to Image:

Document doc = new Document(MyDir + @"in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
foreach (Shape shape in shapes)
{
    if (shape.HasChart)
    {
        using (MemoryStream stream = new MemoryStream())
        {
            ShapeRenderer renderer = shape.GetShapeRenderer();
            renderer.Save(stream, new ImageSaveOptions(SaveFormat.Png));
            builder.MoveTo(shape);
            builder.InsertImage(stream);
        }
    }
}
int shapesCount = shapes.Count;
for (int i = 0; i < shapesCount; i++)
{
    Shape s = (Shape)shapes[i];
    if (s.HasChart)
    {
        s.Remove();
    }
}
doc.Save(MyDir + @"15.6.0.docx");

I hope, this helps.

Best regards,

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for .NET 18.12 update and this Aspose.Words for Java 18.12 update.