How to get text from shape

Hi,

I can’t find a way to get the text of a shape.
Is it possible to retrieve the content of a chart for example?

Thank you in advance.

@flammang Unfortunately, there is no way to extract text content from chart shape. However, you can extract text content from text box shapes. You can achieve this by simply using toString method:

Document doc = new Document("C:\\temp\\in.docx");

// Get shape.
Shape s = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
        
// Print text inside text box.
System.out.println(s.toString(SaveFormat.TEXT).trim());