I am reading a pub file and at some point after casting a Layer to TextLayer I call the getText() method.
Sometimes this returns the name of the layer. Sometimes that print doesn’t appear to be executed at all. I was expecting it to return a String for the full text of the layer but it doesn’t.
Also the code you see commented out was throwing exceptions:
class com.aspose.psd.internal.jx.q (in unnamed module @0x1d269ed7) cannot access class sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl (in module java.base) because module java.base does not export sun.reflect.generics.reflectiveObjects to unnamed module @0x1d269ed7
at com.aspose.psd.internal.jx.q.a(Unknown Source)
at com.aspose.psd.internal.jx.q.a(Unknown Source)
at com.aspose.psd.fileformats.psd.layers.layerresources.Txt2Resource.e(Unknown Source)
at com.aspose.psd.internal.iY.au.a(Unknown Source)
at com.aspose.psd.internal.iY.au.getFont(Unknown Source)
at com.aspose.psd.fileformats.psd.layers.TextLayer.getFont(Unknown Source)
at Main.main(Main.java:81)
Here is the code fragment
if (layer instanceof TextLayer) {
TextLayer textLayer = (TextLayer) layer;
float textBoxHeight = textLayer.getTextBoundBox().getHeight();
float textBoxWidth = textLayer.getTextBoundBox().getHeight();
int textBoxTop = textLayer.getTop();
;
int textBoxLeft = textLayer.getLeft();
String text = textLayer.getText();
System.out.println(“text:” + text);
System.out.println("textBoxHeight " + textBoxHeight);
System.out.println("textBoxWidth " + textBoxWidth);
System.out.println("textBoxTop " + textBoxTop);
System.out.println("textBoxLeft " + textBoxLeft);
String innerText = textLayer.getInnerText();
System.out.println(“innerText:” + innerText);
for (TextFontInfo font : textLayer.getFonts()) {
System.out.println("font: " + font.getFamilyName());
}
// System.out.println(“textLayer.getFont():”+textLayer.getFont()); throws exception
// System.out.println(“textLayer.getTextColor():”+textLayer.getTextColor()); throws exception
// System.out.println(“textLayer.getTextData():”+textLayer.getTextData());