How to highlight uncertainly recognized characters in HTML output

Question

Let's say you want to export the recognition results to HTML format and mark characters that are not well recognized if any. How to do that?

Answer

There are several objects and options like CharParams object that will help you with this. The following code snippet demonstrates how to achieve the goal:

// C#
document.Process();

FREngine.ICharParams suspiciousCharStyle = engineLoader.Engine.CreateCharParams();
suspiciousCharStyle.Color = (255) + (256 * 0) + (65536 * 0); // red color
suspiciousCharStyle.IsSuspicious = true;

FREngine.ICharParams charParams = engineLoader.Engine.CreateCharParams();

foreach (FREngine.FRPage page in document.Pages) {
    foreach(FREngine.IBlock block in page.Layout.Blocks) {
        if(block.Type == FREngine.BlockTypeEnum.BT_Text) {
            var textBlock = block.GetAsTextBlock();
            foreach(FREngine.IParagraph paragraph in textBlock.Text.Paragraphs) {
                for(int i = 0; i < paragraph.Length; i++) {
                    paragraph.GetCharParams(i, charParams);
                    if (charParams.IsSuspicious == true) {
                      paragraph.SetCharParams(i, 1, suspiciousCharStyle,(int)FREngine.CharacterFlags.CFL_Suspicious, (int)FREngine.StyleParamsEnum.SF_Color);
                    }
                }
            }
        }
    }
}

In the Developer's Help, you can find more information about the differences between the CharConfidence and the IsSuspicious properties

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.

Recently viewed