| Leadtools.Forms.Auto Namespace : AutoFormsEngine Class | 

public class AutoFormsEngine : System.IDisposable
'Declaration Public Class AutoFormsEngine Implements System.IDisposable
'Usage Dim instance As AutoFormsEngine
public ref class AutoFormsEngine : public System.IDisposable
Each AutoFormsEngine works on one IMasterFormsRepository which is provided through its constructor.
Important: Different OCR engines might have slight differences in form alignment and recognition. Therefore, it is recommended to use the same Leadtools.Forms.Ocr.OcrEngineType when generating the master forms and when recognizing and processing forms.
The following code shows how to AutoFormsEngine can be used in a multi-threaded server to process forms on demand:
             // The server class, can be a Windows or WCF service
             public class MyServer
             {
                // This is the request to process
                public void ProcessRequest(string fileName)
                {
                   // Unlock the LEADTOOLS support
            
                   // Get the license file path and developer key
                   // This can be fixed or read from a configuration file
                   string licenseFilePath = @"C:\LicenseFile.lic";
                   string developerKey = @"MyDeveloperKey";
                   RasterSupport.SetLicenseFile(licenseFilePath, developerKey);
            
                   // Get the repository instance. This example assumes a disk repository
                   // The path can be fixed or read from configuration file
                   IMasterFormsRepository repository = new DiskMasterFormsRepository(new RasterCodecs(), @"C:\MyRepository");
            
                   // Get the OCR engine type
                   // Again, this can be fixed or read from a configuration file
                   OcrEngineType ocrEngineType = OcrEngineType.Advantage;
             
                   // Create the OCR engines needed for this operation
                   // For OCR Advantage, we only require one instance since the engine supports multi-threading
                   // For all other engines, we must create an instance for each thread
                   int engineCount;
                   if (ocrEngineType == OcrEngineType.Advantage)
                      engineCount = 1;
                   else
                      engineCount = 4; // Or read this from a configuration file
            
                   List<IOcrEngine> ocrEngines = new List<IOcrEngine>();
            
                   // Start the OCR engine(s) using the Thunk Server (For Advantage, this is ignored and not used)
                   for (int i = 0; i < threadCount; i++)
                   {
                      IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(ocrEngineType, true);
                      // Start it
                      ocrEngine.Startup(null, null, null, null);
                      // Add it to the list
                      ocrEngines.Add(ocrEngine);
                   }
            
                   // Optional. Setup the barcode engine
                   BarcodeEngine barcodeEngine = new BarcodeEngine();
            
                   // Create the auto-forms engine
                   AutoFormsEngine engine = new AutoFormsEngine(repository, ocrEngines, barcodeEngine, AutoFormsRecognitionManager.Default);
            
                   bool runInThread = false; // Set this value depending on your server setup
            
                   if (runInThread)
                   {
                      // If this is a Windows Service, then the call to Run must be done in a separate thread
                      // to not block subsequent calls
            
                      ThreadPool.QueueUserWorkItem(delegate()
                      {
                         // Process the request, assuming all categories
                         AutoFormsRunResult result = engine.Run(fileName, null);
            
                         // Call your function to process the result
                         MyProcessResult(result);
                      });
                   }
                   else
                   {
                      // Another type of server, such as a WCF HTTP server, no need to run
                      // in a separate thread since every request is done in its separate process (IIS process)
                      // Process the request, assuming all categories
                      AutoFormsRunResult result = engine.Run(fileName, null);
            
                      // Call your function to process the result
                      MyProcessResult(result);
                   }
                }
             }