Arrow and distance annotations are not working in Java

After doing arrow and distance annotation the application always brokes.

Log: log-arrow-distance-annotation.7z (2.2 KB)
Git project: GitHub - groupdocs-annotation/GroupDocs.Annotation-for-Java: GroupDocs.Annotation for Java examples, plugins, and showcase
Git branch: master
Git revision: aeb3d5d9
Browser: Chrome Version 92.0.4515.159 (Official Build) (64-bit)
SO: Windows 10
Java version: 1.8.0_281
log-arrow-distance-annotation.7z (2.19 KB)

@john.mcqueide

We’re investigating this issue with ticket ID ANNOTATIONJAVA-1335. You’ll be notified in case of any update.

1 Like

@john.mcqueide,
we could not reproduce that error,
could you please give more details how to reproduce it?

Yes, sure. Actually, I have already fixed it on my side. I could fix it by changing the AnnotationMapper class adding a new if clause where it gets the comment text, and where the annotation type is set I changed the toUpperCase to toLowerCase because in the frontend project the annotation type is lower case. With these changes, I fixed the problem. This is the code snippet if you want to check.

Before:

public static AnnotationDataEntity mapAnnotationDataEntity(AnnotationBase annotationInfo, PageInfo pageInfo) {
    ...
    String text = "";
    if (annotationInfo.getMessage() == null && annotationInfo instanceof ITextToReplace) {
        text = ((ITextToReplace) annotationInfo).getTextToReplace();
    } else if (annotationInfo.getMessage() != null) {
        text = annotationInfo.getMessage();
    }
    annotation.setText(text);

    // TODO: remove comment after check all annotations types on main formats
    annotation.setTop(annotationInfo instanceof IBox ? boxY : (annotationInfo instanceof IPoints ? pageInfo.getHeight() - maxY : 0));
    //annotation.setType(char.ToLowerInvariant(annotationTypeName[0]) + annotationTypeName.Substring(1)); !!!
    annotation.setType(annotationTypeName.toUpperCase());
    ...
}

After:

public static AnnotationDataEntity mapAnnotationDataEntity(AnnotationBase annotationInfo, PageInfo pageInfo) {
    ...
    String text = "";
    if (annotationInfo.getMessage() == null && annotationInfo instanceof ITextToReplace) {
        text = ((ITextToReplace) annotationInfo).getTextToReplace();
    //This was the if clause added
    } else if (annotationInfo instanceof IText && ((IText) annotationInfo).getText() != null) {
        text = ((IText) annotationInfo).getText();
    }else if (annotationInfo.getMessage() != null) {
        text = annotationInfo.getMessage();
    }
    annotation.setText(text);

    // TODO: remove comment after check all annotations types on main formats
    annotation.setTop(annotationInfo instanceof IBox ? boxY : (annotationInfo instanceof IPoints ? pageInfo.getHeight() - maxY : 0));
    //annotation.setType(char.ToLowerInvariant(annotationTypeName[0]) + annotationTypeName.Substring(1)); !!!
    //This was the toLowerCase changing
    annotation.setType(annotationTypeName.toLowerCase()); 
    ...
}

@john.mcqueide thanks for the details. We’ll check and notify you in case of any update.

The issues you have found earlier (filed as ANNOTATIONJAVA-1335) have been fixed in this update. This message was posted using Bugs notification tool by vitaliy.rezchikov