Free Support Forum -

Shape.getChars().get(0) throws Exception (878)


On the page 4 in the attached document, there’s a shape with the text “teach”. When I access the shape chars using Aspose.Diagram for Java, an IndexOutOfBoundsException is being thrown.

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(
at java.util.ArrayList.get(
at com.aspose.diagram.CharCollection.get(Unknown Source)

Here’s the code I’m using:

String path = "er-psqa.vsdx";

InputStream inputStream = new FileInputStream(path);

Diagram diagram = new Diagram(inputStream);


ShapeCollection shapes = diagram.getPages().get(4).getShapes();

Shape shape = shapes.get(3);

System.out.println(shape.getType() == TypeValue.GROUP); // this prints "true"

Shape subShape = shape.getShapes().get(3);

System.out.println(subShape.getText().getValue().getText()); // this prints "<cp IX="0"/><pp IX="0"/><tp IX="0"/>teach"


Can you check this?

Zeljko (113.4 KB)

Hi Zeljko,

Thank you for contacting support. Microsoft Visio application stores the formatting attribute for a shape’s text run, such as font, color, style, case, position relative to the baseline, or a point size in the cell element (character section). We unzipped your VSDX drawing and unable to find out the cell element (character section) inside the shape tag which you are retrieving in the code, since Aspose.Diagram for Java API shows an out of index error.