[]
Represents the text map of a page or of a portion of a page. Provides methods for text searching, hit testing etc.
The pixel values used by the text map's methods and properties are determined by the X and Y resolution passed to the GetTextMap(float, float, bool) method to create the text map.
public interface ITextMap : IReadOnlyList<ITextLine>, IReadOnlyCollection<ITextLine>, IEnumerable<ITextLine>, IEnumerable
Indicates whether this ITextMap is valid and can be used.
The ITextMap becomes invalid after editing operations like DeleteText(TextMapFragment, DeleteTextMode), ReplaceText(TextMapFragment, string, Font, float?) etc.
bool Invalid { get; }
Page Page { get; }
Gets the list of text paragraphs.
IReadOnlyList<ITextParagraph> Paragraphs { get; }
Deletes a specified text fragment.
void DeleteText(TextMapFragment fragment, DeleteTextMode mode)
fragment
TextMapFragmentThe fragment to delete.
mode
DeleteTextModeThe text delete mode.
Performs a text search within this text map.
The callback
is called for each found instance.
void FindText(FindTextParams tp, FindTextCallback callback)
tp
FindTextParamsA FindTextParams specifying the search parameters.
callback
FindTextCallbackThe callback method.
Gets the coordinates of a TextLineFragment on the page.
Quadrilateral GetCoords(TextLineFragment tlf)
tlf
TextLineFragmentThe TextLineFragment.
A Quadrilateral containing the text coordinates.
Gets a TextMapFragment that represents the text
within a specified range (from startPos
to endPos
).
void GetFragment(MapPos startPos, MapPos endPos, out TextMapFragment fragment, out string text)
startPos
MapPosThe MapPos specifying the start of the range.
endPos
MapPosThe MapPos specifying the end of the range.
fragment
TextMapFragmentOUT: a TextMapFragment representing the text in the range.
text
stringOUT: the fragment's text.
Gets a TextMapFragment that represents the text of the whole page.
void GetFragment(out TextMapFragment fragment, out string text)
fragment
TextMapFragmentOUT: a TextMapFragment representing the text on the page.
text
stringOUT: the fragment's text.
Gets a TextMapFragment that represents the text
from pos
to the end of the page.
void GetFragmentFromPos(MapPos pos, out TextMapFragment fragment, out string text)
pos
MapPosThe MapPos specifying the start of the range.
fragment
TextMapFragmentOUT: a TextMapFragment representing the text in the range.
text
stringOUT: the fragment's text.
Gets a TextMapFragment that represents the text
from the start of the page to pos
.
void GetFragmentToPos(MapPos pos, out TextMapFragment fragment, out string text)
pos
MapPosThe MapPos specifying the end of the range.
fragment
TextMapFragmentOUT: a TextMapFragment representing the text in the range.
text
stringOUT: the fragment's text.
Gets the array of points defining a polygon with coordinates of a TextLineFragment on the page.
PointF[] GetPoints(TextLineFragment tlf)
tlf
TextLineFragmentThe TextLineFragment.
An array of points defining the polygon of the fragment on a page.
Gets the whole text represented by this map.
string GetText()
The map text.
Gets the text of a TextLineFragment.
string GetText(TextLineFragment br)
br
TextLineFragmentThe TextLineFragment.
The text of the TextLineFragment.
Gets the info about a word at a specified position in a line.
void GetWord(MapPos pos, out int start, out int length, out Quadrilateral bounds)
pos
MapPosstart
intOUT: the start index of the word in the line.
length
intOUT: the length of the word in characters.
bounds
QuadrilateralOUT: the geometric bounds of the word.
Performs hit testing on the map.
This method accepts a pixel location relative to the top left corner of the page, and provides info about the text in that location.
The pixel resolution is the resolution specified when building this text map (see GetTextMap(float, float, bool) and other GetTextMap() overloads).
HitTestInfo HitTest(float x, float y)
x
floatThe X pixel location relative to the top left corner of the page.
y
floatThe Y pixel location relative to the top left corner of the page.
HitTestInfo containing the hit test result.
Replaces a specified text fragment with another text.
void ReplaceText(TextMapFragment fragment, string text, Font font = null, float? fontSize = null)
fragment
TextMapFragmentThe fragment to replace.
text
stringThe replacement text.
font
FontThe font for the replacement text. If null, the current font will be used.
fontSize
float?The font size for the replacement text. If null, the current font size will be used.