Question
How to manually specify an area for text extraction in FineReader Engine 12?
Answer
This code-snippet demonstrates how to specify an extraction area:
FREngine.IRegion region = engineLoader.Engine.CreateRegion();
region.AddRect(244, 287, 1422, 356);
document.Pages[0].Layout.Blocks.AddNew(FREngine.BlockTypeEnum.BT_Text, region, 0);
document.Pages[0].Layout.Blocks[0].GetAsTextBlock().RecognizerParams.SetPredefinedTextLanguage("Japanese");
document.Pages[0].Recognize();
document.Synthesize();
string text = document.Pages[0].Layout.Blocks[0].GetAsTextBlock().Text.Paragraphs[0].Text;
Comments
1 comment
Nishar Ahamed
Hi,
I am using FREngine 12 and trying to extract text from PDF file
I have developed the code based on your code snippet
But unable to get the text
Please look in to the below code snippet and provide your suggestion
---------------------------------------------------------------------
document.AddImageFile( pdffilePath, null, null );
document.Process( null );
IRegion region = engine.CreateRegion();
region.AddRect(244, 287, 422, 356);
IFRPages pages = document.getPages();
int pagecnt = pages.getCount();
displayMessage("Pages:"+pagecnt);
// Get single page in document
IFRPage page = pages.getElement(0);
page.Analyze(pageparams,objparams,Recogparams);
page.Recognize(syn_params,objparams);
ILayout layout = page.getLayout();
page.setLayout(layout);
ILayoutBlocks blocks = layout.getBlocks();
IBlock block = blocks.AddNew(BlockTypeEnum.BT_Text, region, 0);
ITextBlock txtblck = block.GetAsTextBlock();
Recogparams.SetPredefinedTextLanguage("ENGLISH");
IText txt = txtblck.getText();
IParagraphs paras = txt.getParagraphs();
int i = paras.getCount();
displayMessage( "cnt-"+i );
IParagraph parag = paras.getElement(0);
String text = parag.getText();
displayMessage( "text-"+text );
---------------------------------------------------------------------------------
Please find the output below
Please sign in to leave a comment.