How to get word coordinates from the document

Question

Is it possible to receive the word coordinates instead of character coordinates in FineReader Engine 12?

Answer

It is possible to get the coordinates of the word using the Region property. Here is a sample code in C#, that iterates through all found words in the block and saves their coordinates:

FREngine.IBlock block;
// Iterates paragraphs of a text block and retrieves the text
FREngine.ITextBlock textBlock = block.GetAsTextBlock();
int paragraphsCount = textBlock.Text.Paragraphs.Count;
for (int iPar = 0; iPar < paragraphsCount; iPar++)
{
FREngine.IParagraph par = textBlock.Text.Paragraphs[iPar];
int wordsCount = par.Words.Count;
for (int iWord = 0; iWord < wordsCount; iWord++)
{
FREngine.IWord word = par.Words[iWord];
int top = word.Region.Top
int bot = word.Region.Bottom
int l = word.Region.Left
int r = word.Region.Right
//Do something with top, bottom, left, right coordinateds of word
}
}

Please note that the word which this object represents is an internal entity. It is not guaranteed to coincide with the word as understood in the natural language, with the word as defined by regular expression, or with the sequence of characters which is separated from other words by spaces. The main purpose of the Word object is to provide recognition variants for the word. If you need to work with the recognized text, use properties of other objects (e.g., IParagraph::Text).

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.