Charts as Image

Dear Team,

I’m using Aspose Words for Java and I would like to understand how I can save charts embedded in the document as TIFF images.

Can I use the “standard” shape renderer for this or do I need to do something different.

My understanding is that I can get the chart elements, by getting all the shapes and then checking if the shape has a chart, using the hasChart method.$

Many thanks for the clarification.

Regards

Patrick

@PatrickVB,

Thanks for your inquiry. The Shape.HasChart property returns true if this Shape has a Chart. Please use ShapeRenderer.save method as shown below to convert chart to TIFF. Hope this helps you.

Document doc = new Document(MyDir + "input.docx");
ImageSaveOptions options = new ImageSaveOptions(SaveFormat.TIFF);
int i =1;
NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
for (Shape shape : (Iterable<Shape>) shapes)
{
    if(shape.hasChart())
    {
        shape.getShapeRenderer().save("out"+i+".tiff", options);
        i++;
    }
}