documentRange not capturing all words in paragraph?

Sometimes some words are not extracted when I use the method documentRange to captures the Accident Description in a claims loss run. In the screenshot, you can see some of the words are found (outlined in blue) and some are skipped. What could be the reason? Can you suggest how to resolve such situation? I tried using region method, but since the number of lines for Accident Description is not fixed, that method doesn’t work well.

Hi! Looks like what’s happening is that some of the lines in the Accident Description are slightly misaligned – they have a y-coordinate that is less than that of the anchor. They’re not being captured by documentRange which sorts first by y-coordinate and then by x-coordinate by default. You can fix this by adding a small negative offsetY parameter to your method. That way the document range starts just a bit above the “accident description” anchor.

(cross posted into community by admin)