公共字符串[] GetEnumMemberFriendlyNames ()
包含枚举成员友好名称的字符串数组。
如果枚举成员可以“或”在一起,则可以“或”从中的多个成员获取GetEnumMemberValues或GetEnumMemberFriendlyNames转换为一个整数或字符串值(用逗号分隔),并将它们作为设置值传递。这与在. net中使用FlagsAttribute修饰enum是一样的。
如果枚举成员不能“或”在一起(EnumIsFlags是假),则只有一个成员从GetEnumMemberValues或GetEnumMemberFriendlyNames可用作设定值。这与在. net中有一个没有用FlagsAttribute装饰的enum是一样的。
此成员仅在以下情况下有效ValueType是OcrSettingValueType。枚举。
有关支持的特定于引擎的设置及其含义的列表,请参阅OCR引擎特定的设置。
使用Leadtools;使用Leadtools.Codecs;使用Leadtools.Ocr;使用Leadtools.Document.Writer;公共无效OcrSettingManagerExample (){//创建引擎实例使用(IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(ocrengintype . lead)){//使用默认参数启动引擎ocrEngine。启动(零,零,零, LEAD_VARS.OcrLEADRuntimeDir);IOcrSettingManager settingManager = ocreengine . settingManager;//将该引擎支持的所有设置转储到磁盘上的文本文件DumpAllSettings (settingManager);//图像文件到OCR字符串tifFileName = Path.Combine(LEAD_VARS.ImagesDir,“Ocr1.tif”);//保存的文件格式DocumentFormat[] formats = {DocumentFormat。文档格式。pdf};foreach(DocumentFormat格式在格式){//生成输出文件名字符串outFileName =路径。ChangeExtension (tifFileName DocumentWriter.GetFormatFileExtension(格式));控制台。WriteLine ("格式:{0}\nOutput文件:{1}",格式,outFileName);intdetectFontStyles = 0;保龄球recognizeFontAttributes =假;如果(format == DocumentFormat.Text){//这是“文本”格式,我们不需要识别字体属性,如粗体和斜体//这将使识别过程更快控制台。WriteLine ("关闭字体属性");//保存旧的设置detectFontStyles = settingManager。GetEnumValue (“Recognition.Fonts.DetectFontStyles”);recognizeFontAttributes = settingManager。GetBooleanValue (“Recognition.Fonts.RecognizeFontAttributes”);//现在把它们关掉settingManager。SetEnumValue (“Recognition.Fonts.DetectFontStyles”,“没有”);settingManager。SetBooleanValue (“Recognition.Fonts.RecognizeFontAttributes”,假);}//显示我们正在使用的设置控制台。WriteLine ("识别使用这些字体属性设置:");控制台。WriteLine (“Recognition.Fonts。DetectFontStyles:{0}”, settingManager。GetEnumValueAsString (“Recognition.Fonts.DetectFontStyles”));控制台。WriteLine (“Recognition.Fonts。RecognizeFontAttributes:{0}”, settingManager。GetBooleanValue (“Recognition.Fonts.RecognizeFontAttributes”));//识别文件并保存为输出格式使用(IOcrDocument ocrDocument = ocreengine . documentmanager . createdocument ()){//向文档中添加一页IOcrPage ocrPage = ocrDocument.Pages.AddPage(tifFileName,零);//识别页面//注意,无需调用AutoZone或手动添加区域即可调用Recognize。引擎会//检查并自动分区页面ocrPage。识别(零);//将文档保存为PDF格式ocrDocument。保存(outFileName、格式、零);}//重新设置如果(format == DocumentFormat.Text){控制台。WriteLine (“重置原始设置”);settingManager。SetEnumValue (“Recognition.Fonts.DetectFontStyles”, detectFontStyles);settingManager。SetBooleanValue (“Recognition.Fonts.RecognizeFontAttributes”, recognizeFontAttributes);}}//关闭引擎//注意:如果引擎已经启动,调用Dispose也会自动关闭引擎ocrEngine.Shutdown ();}}私人静态无效DumpAllSettings (IOcrSettingManager settingManager){//将所有设置写入磁盘文件字符串settingsFileName = Path.Combine(LEAD_VARS.ImagesDir,“Settings.txt”);使用(StreamWriter writer = File.CreateText(settingsFileName)){作家。WriteLine (“设置”);字符串[] settingNames = settingManager.GetSettingNames();foreach(字符串settingName在settingNames){IOcrSettingDescriptor sd = settingManager.GetSettingDescriptor(settingName);作家。WriteLine ("姓名:{0}", sd.Name);作家。WriteLine (" ValueType: {0}", sd.ValueType);作家。WriteLine (" FriendlyName: {0}", sd.FriendlyName);开关(sd.ValueType){情况下OcrSettingValueType。BeginCategory:作家。WriteLine ("-------------------------------------");打破;情况下OcrSettingValueType。整数:作家。WriteLine (单位:{0}, sd.Units);作家。WriteLine (" IntegerMinimumValue: {0}", sd.IntegerMinimumValue);作家。WriteLine (" IntegerMaximumValue: {0}", sd.IntegerMaximumValue);打破;情况下OcrSettingValueType。枚举:作家。WriteLine (" EnumIsFlags: {0}", sd.EnumIsFlags);作家。WriteLine (“EnumMemberFriendlyNames”);{int[] values = sd.GetEnumMemberValues();字符串[] names = sd.GetEnumMemberFriendlyNames();为(intI = 0;i < values.Length;我+ +){作家。WriteLine (“{0}:{1}”,名称[i],值[i]);}}打破;情况下OcrSettingValueType。双:作家。WriteLine (单位:{0}, sd.Units);作家。WriteLine (DoubleMinimumValue: {0}, sd.DoubleMinimumValue);作家。WriteLine (DoubleMaximumValue: {0}, sd.DoubleMaximumValue);打破;情况下OcrSettingValueType。布尔:打破;情况下OcrSettingValueType。性格:打破;情况下OcrSettingValueType。字符串:作家。WriteLine (StringMaximumLength: {0}, sd.StringMaximumLength);作家。WriteLine (" StringNullAllowed: {0}", sd.StringNullAllowed);打破;情况下OcrSettingValueType。矩形:打破;情况下OcrSettingValueType。EndCategory:打破;默认的:打破;}}}}静态类LEAD_VARS{公共常量字符串ImagesDir =@“C: \ LEADTOOLS22 \ Resources \图片”;公共常量字符串OcrLEADRuntimeDir =@“C: \ LEADTOOLS22 \ Bin \常见\ OcrLEADRuntime”;}