How to extract smart&chart&mathoffice and save it as an image using aspose.words for java?

for (int sectionIndex = 0; sectionIndex < wordDocument.getSections().getCount(); sectionIndex++) {
            for (Shape shape : shapes) {
                // extract image
                if (shape.hasImage()) {
                    String imageFileName = MessageFormat.format(
                            "ExtractedImages_{0}{1}",
                            imageIndex,
                            FileFormatUtil.imageTypeToExtension(shape.getImageData().getImageType())
                    );
                    shape.getImageData().save(outpath + imageFileName);
                    imageIndex++;
                }

                // extract smart
                if (shape.hasSmartArt()) {
                    smartIndex++;
                }

                // extract chart
                if (shape.hasChart()) {
                    chartIndex++;
                }
}

@DiDiDiDiDi You can use ShapeRenderer to render smart art and chart shapes to image. And OfficeMathRenderer to render office math equations. For example see the following code:

Document doc = new Document("C:\\Temp\\in.docx");
Iterable<Shape> shapes = doc.getChildNodes(NodeType.SHAPE, true);

int smartArtIndex = 0;
int chartIndex = 0;
for (Shape s : shapes)
{
    if (s.hasSmartArt())
    {
        s.getShapeRenderer().save(String.format("C:\\Temp\\smartart_%d.png", smartArtIndex), new ImageSaveOptions(SaveFormat.PNG));
        smartArtIndex++;
    }

    if (s.hasChart())
    {
        s.getShapeRenderer().save(String.format("C:\\Temp\\chart_%d.png", chartIndex), new ImageSaveOptions(SaveFormat.PNG));
        chartIndex++;
    }
}

Iterable<OfficeMath> maths = doc.getChildNodes(NodeType.OFFICE_MATH, true);
int officeMathIndex = 0;
for (OfficeMath m : maths)
{
    if (m.getParentNode().getNodeType() != NodeType.OFFICE_MATH)
    {
        m.getMathRenderer().save(String.format("C:\\Temp\\math_%d.png", officeMathIndex), new ImageSaveOptions(SaveFormat.PNG));
        officeMathIndex++;
    }
}