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

Free Support Forum - aspose.com

Find surrounding text for match

Hello. Can you suggest the algorithm to search surrounding test.
I need to find specific word in document and get its rectangle, this quite easy task to do.
But next challenge is to show the context where this word was found. I need to show 2 words before the match and 4 words after the match. I was trying to use regular expression for it, but the problem is that as a result I get the match for entire regex expression and rectangle will have boundaries for this entire match. But I need to have boundaries to that specific “word” only. I unable to find how to use Regex capture groups( like I may do with the pure C# text search), seems Aspose doesn’t have that functionality. Can you help to achieve desired result?

@grinaypps

Could you please attach the input PDF and expected output here for our reference? We will then provide you more information on it.