Hi,
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 -
Code
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()));
linkText.visit(document.getPages().get_Item(page.getNumber()));
TextFragment links = null;
for (TextFragment fragment : linkText.getTextFragments()) {
if (fragment != null) {
System.out.println(fragment.getText());
}
}
}
}
Output:
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