FormRecognitionEngine RecognitionEngine = new FormRecognitionEngine();
RasterCodecs.Startup(); RasterCodecs FormsCodec = new RasterCodecs(); DocumentWriter docWriter = null; string ocrInstallationDirectory = ""; //use default installation IOcrEngine FormsOcrEngine; FormsOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false); FormsOcrEngine.Startup(FormsCodec, docWriter, System.IO.Path.GetTempPath(), ocrInstallationDirectory); OcrObjectsManager ocrObjectManager = new OcrObjectsManager(FormsOcrEngine); RecognitionEngine.ObjectsManagers.Add(ocrObjectManager);
FormRecognitionAttributes attributes; attributes = RecognitionEngine.CreateMasterForm(name, Guid.Empty, null);
for(int i = 1; i<= image.PageCount; i++) { image.Page = i; AddPageToMasterForm(image, attributes); }
RecognitionEngine.CloseMasterForm(attributes);
FormProcessingEngine ProcessingEngine = new FormProcessingEngine();
IOcrEngine FormsOcrEngine; FormsOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Professional, false); FormsOcrEngine.Startup(null, null, null); ProcessingEngine.OcrEngine = FormsOcrEngine; BarcodeEngine FormsBarcodeEngine = new BarcodeEngine(); ProcessingEngine.BarcodeEngine = FormsBarcodeEngine;
List<FormField> fields;
TextFormField text = new TextFormField(); text.Name = name; text.Bounds = new LogicalRectangle(100, 500, 50, 75, LogicalUnit.Pixel); fields.Add(text); OmrFormField omr = new OmrFormField(); omr.Name = name; omr.Bounds = new LogicalRectangle(200, 300, 25, 25, LogicalUnit.Pixel); fields.Add(omr); ImageFormField image = new ImageFormField(); image.Name = name; image.Bounds = new LogicalRectangle(100, 1000, 300, 50, LogicalUnit.Pixel); ; fields.Add(image); BarcodeFormField barcode = new BarcodeFormField(); barcode.Name = name; barcode.Bounds = new LogicalRectangle(700, 100, 300, 100, LogicalUnit.Pixel); fields.Add(barcode);
FormPage page = new FormPage(image.Page, image.XResolution, image.YResolution); page.AddRange(fields);
ProcessingEngine.Pages.Add(formPage);
DiskMasterFormsRepository repository; repository = new DiskMasterFormsRepository(codecs, @"C:\Forms\FormsDemo\OCR_Test");
repository.RootCategory.AddMasterForm(attributes, ProcessingEngine.Pages, image);