Steps to Generate a Master Form and save it to a Master Repository.


  1. Create and Initialize the Form Recognition Engine using the Forms Recognition Engine.

    FormRecognitionEngine RecognitionEngine = new FormRecognitionEngine();

  2. Create and add the desired Object managers using the RecognitionObjectsManager.

        RasterCodecs FormsCodec = new RasterCodecs(); 
        DocumentWriter docWriter = null; 
        string ocrInstallationDirectory = ""; //use default installation 
        IOcrEngine FormsOcrEngine; 
        FormsOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false); 
        FormsOcrEngine.Startup(FormsCodec, docWriter, System.IO.Path.GetTempPath(), ocrInstallationDirectory); 
        OcrObjectsManager ocrObjectManager = new OcrObjectsManager(FormsOcrEngine); 

  3. Create the Master Form (or several) attributes using the CreateMasterForm.

    FormRecognitionAttributes attributes; 
        attributes = RecognitionEngine.CreateMasterForm(name, Guid.Empty, null); 

  4. Add pages to the Master Form using the AddMasterFormPage Method.

    for(int i = 1; i<= image.PageCount; i++)  
         image.Page = i; 
         AddPageToMasterForm(image, attributes);  

  5. Close the Master Form using the CloseMasterForm Method.


Processing Fields:

  1. Create the Form Processing Engine using the Class.

    FormProcessingEngine ProcessingEngine = new FormProcessingEngine();

  2. Initialize the Form Processing Engine with the OCR engine, Barcode engine, or both engines.

    IOcrEngine FormsOcrEngine; 
        FormsOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false); 
        FormsOcrEngine.Startup(null, null, null, @"C:\LEADTOOLS 20\Bin\Common\OcrLEADRuntime"); 
        ProcessingEngine.OcrEngine = FormsOcrEngine; 
        BarcodeEngine FormsBarcodeEngine = new BarcodeEngine(); 
        ProcessingEngine.BarcodeEngine = FormsBarcodeEngine; 

  3. Create the Form Fields list.

    List<FormField> fields;

  4. Add your form fields to the lists.

    TextFormField text = new TextFormField(); 
        text.Name = name; 
        text.Bounds = new LeadRect(100, 500, 50, 75); 
        OmrFormField omr = new OmrFormField(); 
        omr.Name = name; 
        omr.Bounds = new LeadRect(200, 300, 25, 25); 
        ImageFormField image = new ImageFormField(); 
        image.Name = name; 
        image.Bounds = new LeadRect(100, 1000, 300, 50); ; 
        BarcodeFormField barcode = new BarcodeFormField(); 
        barcode.Name = name; 
        barcode.Bounds = new LeadRect(700, 100, 300, 100); 

  5. Create a page and add the fields to it.

    FormPage page = new FormPage(image.Page, image.XResolution, image.YResolution); 

  6. Add pages to the processing engine.


Save Master Form to disk repository:

  1. Create a Repository using the Leadtools.Forms.Auto.DiskMasterFormsRepository Class.

    DiskMasterFormsRepository repository; 
        repository = new DiskMasterFormsRepository(codecs, @"C:\Forms\FormsDemo\OCR_Test"); 

  2. Save the Master Form to the repository at the root category.

    repository.RootCategory.AddMasterForm(attributes, ProcessingEngine.Pages, image);

Help Version 20.0.2020.4.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Imaging, Medical, and Document