GetTextInAreaEx
Text, extraction
Description
Extracts those text blocks of the current page that intersect the given rectangle and writes each block's page, bounding rectangle and text into Hits, returning the total number of matching blocks. Blocks are written in page order up to the length of the caller's array, so an array that is too short still reports the full count.
Syntax
Delphi
Function TPDFlib.GetTextInAreaEx(Left, Top, Width, Height: Double; Var Hits: Array Of TPDFlibSearchHit): Integer;
Parameters
Left and Top are the left and upper edges of the query rectangle, expressed in the current measurement unit and measured from the origin corner chosen with SetOrigin. Width and Height are the extents of the rectangle in the same units and must be positive, since a zero or negative extent matches no block. Hits receives one record per intersecting block, in page order, with Page holding the selected page number, Left, Top, Right and Bottom holding the block box and MatchText holding the block's whole text.
Return values
The number of text blocks on the current page whose box intersects the rectangle, which can exceed Length(Hits): in that case only the first Length(Hits) records are written and the remainder are counted but discarded. The result is 0 when no document is open, when the page has no extractable text, or when no block reaches the rectangle.
Remarks
Only the currently selected page is read, so select the page first; the extraction runs the block pass of the text funnel, which means MatchText is a whole line or block rather than the matched run. All document-level extraction options set through SetTextExtractOptions apply, including the area installed by SetTextExtractArea: that area and the rectangle passed here intersect, so a block inside this rectangle can still be missing when it falls outside the configured area. Block boxes are the union of the four corner points of each block quadrilateral, so rotated text is reported through an enclosing axis-aligned box that is larger than the glyphs themselves. Every record stores the smallest numeric value in Left and Top and the largest in Right and Bottom, using exactly the origin and unit transform of GetTextBlockBound, which is what makes a single rectangle comparison work under both the bottom-left and the top-left origins.