2015-05-22 27 views
3

我使用LEADTOOLS OCRLEADTOOLS - OcrException - OCR未啓用

我引用下列DLL:

Leadtools.dll 
Leadtools.Barcode.oneD.dll 
Leadtools.codecs.dll 
Leadtools.codecs.fax.dll 
Leadtools.codecs.png.dll 
Leadtools.codecs.tif.dll 
Leadtools.Forms.DocumentWriters.dll 
Leadtools.forms.ocr.dll 
Leadtools.forms.ocr.Advantage.dll 

以下代碼爲PNG文件轉換爲PDF

private void button1_Click(object sender, EventArgs e) 
{ 

    try 
    { 

     string sourceFile = @"C:\Users\cf\Desktop\OcrTest\Images\Capture.PNG"; 
     string targetFile = Path.ChangeExtension(sourceFile, "pdf"); 

     using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false)) 
     { 
      ocrEngine.Startup(null, null, null, @"C:\LEADTOOLS 19\Bin\Common\OcrAdvantageRuntime"); 
      ocrEngine.AutoRecognizeManager.Run(sourceFile, targetFile, Leadtools.Forms.DocumentWriters.DocumentFormat.Pdf, null, null); 
      Process.Start(targetFile); 

     } 
    } 

    catch (OcrSupportLockedException ex) 
    { 
     Console.WriteLine("Support is locked. You need to unlock '{0}' in this engine to use this feature", ex.SupportType); 
    } 
    catch (OcrException ex) 
    { 
     Console.WriteLine("OCR Error\nCode: {0}\nMessage:{1}", ex.Code, ex.Message); 
    } 
    catch (RasterException ex) 
    { 
     Console.WriteLine("LEADTOOLS Error\nCode: {0}\nMessage:{1}", ex.Code, ex.Message); 
    } 
    catch (Exception ex) 
    { 
     Console.WriteLine("System Error\nMessage:{0}", ex.Message); 
    } 


} 

以下行返回OcrException

Ocr Not Enabled 

隨着代碼:-1760

我無法弄清楚爲什麼發生這種情況

任何幫助,將不勝感激

回答

1

錯誤-1760「OCR沒有啓用」最有可能是試圖用一個引起LEADTOOLS OCR引擎沒有適當的許可證文件或解鎖密鑰。 您可以在使用CreateEngine()之前通過調用RasterSupport.IsLocked(RasterSupportType.OcrAdvantage)來檢查。如果函數返回TRUE,表示鎖定,則不應嘗試使用OCR功能。

要使用OCR,您需要擁有一個有效的工具包許可證,其中包含OCR支持,例如LEADTOOLS Document Imaging Suite,或者擁有有效的免費評估許可證。

啓用OCR功能的機制取決於工具包版本。如果您已擁有有效的解鎖密鑰(v17及更早版本)或有效的許可證文件(版本17.5及更高版本),但仍然失敗,請將該許可證/解鎖信息發送到[email protected],因爲您不應發佈此類詳細信息在公共論壇上。

如果您沒有這些詳細信息,請將您的工具包序列號發送到[email protected](也不要在此發佈!)您也可以在工作時間使用我們的在線聊天服務聯繫支持或銷售。