Text In a shape

Hello,

I have a problem getting the text of a shape that has just one letter.When I tried to add more than one letter the text value of the shape is correct but when it is just one letter the text value is empty.
In the attached file you will find a visio file containing two elements in the group.one with the text value “A” and the other one is with text “C5”.
in the simple code below you will see in the console that only the text of the second element is correct. the first one is empty (just with tags but no text value).

License license = new License();
[//license.setLicense](https://license.setlicense/)(“C://Users//ark//Desktop//Visio Import//Aspose.Total.Java.lic.resj”);
license.setLicense(Licenses.class.getResourceAsStream("/Aspose.Total.Java.lic.resj"));

// The path to the documents directory.
String dataDir = “C://Users//ark//Desktop//Visio Import//Diagrams//”;
// Call the diagram constructor to load diagram
Diagram vdxDiagram = new Diagram(dataDir + “testLabelNotShowing.vsd”);
for (Shape shape : (Iterable) vdxDiagram.getPages().get(0).getShapes()) {
if ((shape.getType() == TypeValue.GROUP) && (shape.getShapes().getCount() > 0)) {
System.out.println(“ID group :” + shape.getID() + " " + shape.getText().getValue().getText());
for (Shape subShape : (Iterable) shape.getShapes()) {
System.out.println(“ID :” + subShape.getID() + " " + shape.getText().getValue().getText());
}
} else {
System.out.println(“ID :” + shape.getID() + " " + shape.getText().getValue().getText());
}
}
}

Hi Achraf,


Thank you for contacting us. Please use the latest version of Aspose.Diagram for Java 5.5.0 and source code below:

[Java]
public class TestCls {
static String text = “”;
public static void main(String[] args) throws Exception
{
License licDiagram = new License();
licDiagram.setLicense(“C:\Aspose.Total.Java.lic”);
Diagram diagram = new Diagram(“C:/ad/test462/testLabelNotShowing.vsd”);

Page page = diagram.getPages().getPage(“Processing of Transactions”);
for (com.aspose.diagram.Shape shape : (Iterable) page.getShapes())
{
GetShapeText(shape);
}
System.out.println(TestCls.text);
}

static void GetShapeText(Shape shape)
{
TestCls.text += (shape.getText().getValue().getText().replaceAll("\<.*?>",""));

// for image shapes
if (shape.getType() == TypeValue.FOREIGN)
TestCls500.text += (shape.getName());

// for group shapes
if (shape.getType() == TypeValue.GROUP)
for(Shape subshape : (Iterable) shape.getShapes())
{
GetShapeText(subshape);
}
}
}

Results:
A
C5

We hope, this helps. Please let us know in case of any ambiguity or questions.