我在Asp.Net MVC web项目中实现了Dynamic Dot Net Twain OCR功能,当我将OCRResultformat作为PDFPlainText提供输出时,当我将OCRResultFormat作为PDFImageOverText时,它会抛出异常
“类型'System.StackOverflowException'的未处理异常 发生在DynamicDotNetTWAIN.dll“........
任何帮助都将受到高度赞赏。 我的代码如下。
DynamicDotNetTwain dynamicDotNetTwain1 = new DynamicDotNetTwain();
dynamicDotNetTwain1.LicenseKeys = "A3EDADA92DCE76E49D628E3AE59AC978;A3EDADA92DCE76E447421F637B0A5E35";
dynamicDotNetTwain1.IfThrowException = true;
string TessDataPath = @"E:\metsi\E-archive source\Source\Source\EArchive.Web\Redistributable\Resources\";
dynamicDotNetTwain1.OCRTessDataPath = TessDataPath;
dynamicDotNetTwain1.OCRLanguage = "eng";
dynamicDotNetTwain1.OCRResultFormat = (Dynamsoft.DotNet.TWAIN.OCR.ResultFormat)2;
string strDllPath = @"E:\metsi\E-archive source\Source\Source\EArchive.Web\Redistributable\Resources\OCR\";
dynamicDotNetTwain1.OCRDllPath = strDllPath;
//string[] source = new string[] { @"E:\metsi\E-archive source\Source\Source\EArchive.Web\Documents\0606dbbd-3d24-44b4-8700-17ece39f873e.tif" };
dynamicDotNetTwain1.LoadImage(sourcePath);
//short a= dynamicDotNetTwain1.CurrentImageIndexInBuffer;
if (dynamicDotNetTwain1.CurrentImageIndexInBuffer < 0)
{
return false;
}
//int bottom = dynamicDotNetTwain1.GetImage(dynamicDotNetTwain1.CurrentImageIndexInBuffer).Height;
//int left = 0;
//int right = dynamicDotNetTwain1.GetImage(dynamicDotNetTwain1.CurrentImageIndexInBuffer).Width;
//int top = 0;
//IndexList index = new IndexList();
//index.Add(0);
byte[] sbytes = null;
sbytes = dynamicDotNetTwain1.OCR(dynamicDotNetTwain1.CurrentSelectedImageIndicesInBuffer);
if (sbytes != null && sbytes.Length > 0)
{
System.IO.File.WriteAllBytes(destinationPath, sbytes);
}
else
{
System.IO.File.WriteAllBytes(destinationPath, null);
}
return true;
}