Is it possible to find the text position using iText? I saw the RenderListener interface that has beginTextBlock, renderText and endTextBlock but
The TextRenderInfo
parameter passed to renderText()
contains that information. Specifically, you need to look at the return values from getBaseLine()
and getAscentLine()
.
These two line segments are in User Space (what you see on the page). They define the bounding box of the current chunk of text. Kind of a goofy way of presenting it, but it works.
Note that stuffing the end points into a Rectangle
may not work depending on how the text is rotated. If you're not worried about rotation, then it's no big deal. If you are, you need to start monkeying with trig. Have "fun".