We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Read link text

I want to read/get link text but when i was tried to read link text with specific link rectangle, it automatically read rectangle boundary touching text as link text.
#I am tried to reduce height of rectangle but it is not works.
#I am tried to reduce LLY and URY of rectangle, but it is not works.
So please suggest me how can i read only rectangle text not next line text.
Please find the below code I used to read link text -
Document document = new Document(“C:\Users\saurav.saxena\Documents\test\sample.pdf”);
TextFragmentAbsorber linkText = new TextFragmentAbsorber();
for (Page page : document.getPages()) {
for (Annotation annotation : page.getAnnotations())
if (annotation.getAnnotationType() == AnnotationType.Link) {
LinkAnnotation linkAnnotation = (LinkAnnotation) annotation;
linkText.setTextSearchOptions(new TextSearchOptions(linkAnnotation.getRect()));
TextFragment links = null;
for (TextFragment fragment : linkText.getTextFragments()) {
if (fragment != null) {

Virtual Mechanics tutorials
xt. And more text. And mor
Please review the sample file and code and let me know.

sample.pdf (2.5 KB)

Thanks and Regards
Saurav Saxenna


We tested the scenario with Aspose.PDF for Java 20.6 and were unable to notice any issue as code returned following output:

Virtual Mechanics tutorials

Would you please make sure to use the latest version. In case you still face any issue, please let us know.

Thank you for your support @asad.ali.
I am using version 19.1. After changed version issue got resolved.

Thanks and regards
Saurav Saxena


It is good to know that your issue has been resolved. Please keep using our API and in case you need further assistance, please feel free to let us know.