gpt4 book ai didi

c# - Leadtools - OcrException - ocr 未启用

转载 作者:行者123 更新时间:2023-11-30 16:07:44 28 4
gpt4 key购买 nike

我正在使用 Leadtools OCR

我引用了以下 DLLS:

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

我不知道为什么会这样

任何帮助将不胜感激

最佳答案

错误 -1760“OCR 未启用”很可能是由于在没有适当的许可文件或解锁 key 的情况下尝试使用 LEADTOOLS OCR 引擎之一造成的。您可以在使用 CreateEngine() 之前通过调用 RasterSupport.IsLocked(RasterSupportType.OcrAdvantage) 进行检查。如果函数返回 TRUE,这意味着已锁定,则不应尝试使用 OCR 功能。

要使用 OCR,您需要拥有支持 OCR 的有效工具包许可证,例如 LEADTOOLS Document Imaging Suite,或者拥有有效的免费评估许可证。

启用 OCR 功能的机制取决于工具包版本。如果您已经拥有有效的解锁 key (v17 及更早版本)或有效的许可文件(17.5 及更高版本),但仍然失败,请将该许可/解锁信息发送至 support@leadtools.com,因为您不应发布此类详细信息在公共(public)论坛上。

如果您没有这些详细信息,请将您的工具包序列号发送至 sales@leadtools.com(也不要在此处发布!)您还可以在工作时间使用我们的在线聊天服务联系支持或销售人员。

关于c# - Leadtools - OcrException - ocr 未启用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30389657/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com