HI,
during my work on OneNote with Aspose.note i found that i can’t check if image have link
there is no method to check if there is hyperlink on the image, image.ishyperlink() for example.
so i try to receive the hyperlink as with the next method:
String link = image.getHyperlinkUrl();
but this trow exception NULLPointer as in your code the string never initialized if the setHyperlink didn’t call.
can you please add a method to check if there is a link or return an empty string in case there is no and not trow exception please?
The exception would be thrown for the method call if there is no hyperlink attached to the image. I think you may handle the exception which is thrown against “Image.getHyperlinkUrl()” when there is no hyperlink attached to the image. Can’t you handle the exception in try…catch block?
i can add try-catch, but this should be documented don’t you agree? moreover, personally, i think that we should have a method to check if link exist at the image object (FYI - like in Richtext).
Your provided detail makes sense. We have logged a ticket with an id “NOTEJAVA-1183” for your requirements. We will evaluate if we could support your suggested API (e.g., Check if link exists at the Image object). Once we have an update on it, we will let you know.
Could you please try our latest version/fix: Aspose.Note for Java v23.7. Please refer to the following code segment that should run without exception.
String link = image.getHyperlinkUrl();
if(link == null) {
System.out.println("link is null");
}
else {
System.out.println(link);
}
If you still find the exception with latest version, kindly zip and attach your sample document and sample code, we will check it soon.