1、ABBYY安装完成后

这个目录下存放示例代码,C:\ProgramData\ABBYY\SDK\11\FineReader Engine\Samples

2、新建工程把Hello 里面的代码和SamplesConfig.java 放入工程中

3、直接贴代码

SamplesConfig.java 用于存放序列号,本地安装路径等信息
package com.abbyy.test;// � 2013 ABBYY Production LLC
// SAMPLES code is property of ABBYY, exclusive rights are reserved.
//
// DEVELOPER is allowed to incorporate SAMPLES into his own APPLICATION and modify it under
// the  terms of  License Agreement between  ABBYY and DEVELOPER.// Auto-generated config-file for FineReader Engine Java samplespublic class SamplesConfig {/*** Folder with FRE dll* 设置ABBYY所需dll文件地址*/public static String GetDllFolder() {if( is64BitJVMArchitecture() ) {return "C:\\Program Files\\ABBYY SDK\\11\\FineReader Engine\\Bin64";} else {return "C:\\Program Files\\ABBYY SDK\\11\\FineReader Engine\\Bin";}}/*** 设置 ABBYY所需 秘钥* Return developer serial number for FRE*/public static String GetDeveloperSN() {return "SWTT-1101-0006-5071-4505-1208";  //申请试用版序列号}/*** Return full path to Samples directory* 设置ABBYY转换后生成路径*/public static String GetSamplesFolder() {
//      return "Directory\\where\\samples\\reside";return "D:\\zhjwFile\\05_abbyy";}/*** Determines whether the JVM architecture is a 64-bit architecture* 判断当前jdk 所属版本是64还是32*/private static boolean is64BitJVMArchitecture(){String jvmKeys [] = {"sun.arch.data.model", "com.ibm.vm.bitmode", "os.arch"};for( String key : jvmKeys ) {String property = System.getProperty( key );if( property != null ) {if( property.indexOf( "64" ) >= 0 ) {return true;} else if( property.indexOf( "32" ) >= 0 ) {return false;} else if( property.indexOf( "86" ) >= 0 ) {return false;}}}return false;}
}
Hello.java 单个文件的转换
package com.abbyy.test.Hello;import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;// (c) 2013 ABBYY Production LLC
// SAMPLES code is property of ABBYY, exclusive rights are reserved.
//
// DEVELOPER is allowed to incorporate SAMPLES into his own APPLICATION and modify it under
// the  terms of  License Agreement between  ABBYY and DEVELOPER.// ABBYY FineReader Engine 11 Sample// This sample shows basic steps of ABBYY FineReader Engine usage:
// Initializing, opening image file, recognition and export.
import com.abbyy.FREngine.*;
import com.abbyy.test.SamplesConfig;public class Hello {public static void main(String[] args) {try {Hello application = new Hello();application.Run();} catch (Exception ex) {displayMessage(ex.getMessage());ex.printStackTrace();}}public void Run() throws Exception {// 加载ABBYY转换引擎loadEngine();try {// 使用ABBYY FineReader引擎进行处理processWithEngine();} finally {// 卸载ABBYY FineReader引擎unloadEngine();}}/*** 加载本地环境,创建转换引擎* @throws Exception*/private void loadEngine() throws Exception {displayMessage("初始化引擎…");engine = Engine.GetEngineObject(SamplesConfig.GetDllFolder(), SamplesConfig.GetDeveloperSN());}/*** 使用ABBYY FineReader引擎进行处理*/private void processWithEngine() {try {// 设置转换参数setupFREngine();// 转换样例图片processImage();} catch (Exception ex) {displayMessage(ex.getMessage());}}/*** 设置转换参数*/private void setupFREngine() {displayMessage("预定义的配置文件加载…");engine.LoadPredefinedProfile("Default");// Possible profile names are:// "DocumentConversion_Accuracy",    文档转换精度,// "DocumentConversion_Speed",       文档转换速度// "DocumentArchiving_Accuracy",     文档归档准确性// "DocumentArchiving_Speed",        文档归档的速度// "BookArchiving_Accuracy",         书存档准确性// "BookArchiving_Speed",            书存档速度// "TextExtraction_Accuracy",        文本提取的准确性// "TextExtraction_Speed",           文本提取的速度// "FieldLevelRecognition",          字段级识别// "BarcodeRecognition_Accuracy",    条形码识别精度// "BarcodeRecognition_Speed",       条形码识别速度// "HighCompressedImageOnlyPdf",     高度压缩图像Pdf// "BusinessCardsProcessing",        名片处理// "EngineeringDrawingsProcessing",  工程图纸处理// "Version9Compatibility",          Version9兼容性// "Default"                         默认}/*** 转换图片*/private void processImage() {String fileName = "Demo_ChinesePRC.tif";    //Demo_ChinesePRC.tifString imagePath = SamplesConfig.GetSamplesFolder() + "\\"+fileName;try {// Don't recognize PDF file with a textual content, just copy it// 不要识别带有文本内容的PDF文件,只需复制它if (engine.IsPdfWithTextualContent(imagePath, null)) {displayMessage("复制的结果……");String resultPath = SamplesConfig.GetSamplesFolder() + "\\"+fileName+".pdf";Files.copy(Paths.get(imagePath), Paths.get(resultPath), StandardCopyOption.REPLACE_EXISTING);return;}// 创建文档IFRDocument document = engine.CreateFRDocument();try {// Add image file to documentdisplayMessage("加载图片……");document.AddImageFile(imagePath, null, null);// Process documentdisplayMessage("过程……");// 创建识别器参数类IDocumentProcessingParams dpp = engine.CreateDocumentProcessingParams();IPageProcessingParams ppp = dpp.getPageProcessingParams();ppp.getRecognizerParams().SetPredefinedTextLanguage("ChinesePRC+English");  //设置语言为简体中文和英语document.Process(dpp);// Save resultsdisplayMessage("保存结果……");// 使用默认参数将结果保存到rtfString rtfExportPath = SamplesConfig.GetSamplesFolder() + "\\"+fileName+".rtf";document.Export(rtfExportPath, FileExportFormatEnum.FEF_RTF, null);// Save results to pdf using 'balanced' scenario// 使用“平衡”场景将结果保存为pdfIPDFExportParams pdfParams = engine.CreatePDFExportParams();pdfParams.setScenario(PDFExportScenarioEnum.PES_Balanced);String pdfExportPath = SamplesConfig.GetSamplesFolder() + "\\"+fileName+".pdf";document.Export(pdfExportPath, FileExportFormatEnum.FEF_PDF, pdfParams);} finally {// Close documentdocument.Close();}} catch (Exception ex) {displayMessage(ex.getMessage());}}/*** 卸载ABBYY FineReader引擎* @throws Exception*/private void unloadEngine() throws Exception {displayMessage("卸载ABBYY FineReader引擎...");engine = null;Engine.DeinitializeEngine();}private static void displayMessage(String message) {System.out.println(message);}private IEngine engine = null;
}

基于ABBYY SDK 实现java版本 Hello 功能!相关推荐

  1. java 微博sdk_Java基于新浪微博SDK实现发微博的功能

    背景 最近用实现了一个简单的发微博的功能. 新浪微博的SDK已经经历了多次更新,而网上的资料.教程大多还是基于旧版本的,很多细节上有了一些变化.本文将基于最新的新浪微博SDK介绍发微博的过程. 简介 ...

  2. 在一个Java版本上运行Eclipse IDE,但在另一个Java版本上运行

    Java™开发人员 (和其他Java开发人员变体)的Eclipse IDE本身就是用于构建Java应用程序的Java应用程序. 这种关系可能会让您的大脑有些奇怪. Eclipse IDE几乎完全用Ja ...

  3. 如何基于IM SDK从零开发移动端聊天功能

    IM即时通讯技术的发展 即时通讯(Instant Messaging)是一种基于互联网的即时交流消息的业务. 实时聊天交互功能是市面上主流APP的重要功能之一,人们所熟悉的就是微信,QQ的聊天消息系统 ...

  4. puking java_GitHub - pukingli/mpsdk4j: JAVA微信公平台开发SDK,没有复杂的功能,一切源于微信API,愿你会喜欢使用。...

    MPSDK4J 目录 1.引言 双11是一个令不少人狂欢的日子,今天你买了么?或许在那XXX亿的曲线中能找到你的影子哟,呵~,不过这与俺无关了,只是借用这个双11来纪念一下而已.从事微信公众平台开发也 ...

  5. MPSDK4J 是JAVA微信公平台开发SDK,没有复杂的功能,一切源于微信API,愿你会喜欢使用。-- 题记

    MPSDK4J 是JAVA微信公平台开发SDK,没有复杂的功能,一切源于微信API,愿你会喜欢使用.-- 题记 1.介绍 MPSDK4J,非常直观的阐述了此项目的意义所在.没错,它就是JAVA语言环境 ...

  6. RxJava详解(基于2.X版本的功能操作符)

    本章节讲述RxJava基于2.X版本的功能操作符 1.subscribe() <1> 作用 订阅,即连接观察者 & 被观察者. <2> 代码&结果 https: ...

  7. 乐鑫esp8266学习rtos3.0笔记第6篇:esp8266-12模块基于rtos3.1版本ota功能远程空中升级固件,官网之上增加dns域名解析!(附带demo)

    本系列博客学习由非官方人员 半颗心脏 潜心所力所写,仅仅做个人技术交流分享,不做任何商业用途.如有不对之处,请留言,本人及时更改. 1. Esp8266之 搭建开发环境,开始一个"hello ...

  8. Java版本的Bot Framework SDK

    微软为了鼓励Java开发人员开发bot,在上个月推出了Java的Bot SDK v4.6版本,目前还在Preview版本,相信不用多久就可以赶上其他版本了. 我的java还停留在 n 年前的水平,但是 ...

  9. java 文本查找_Java基于正则表达式实现查找匹配的文本功能【经典实例】

    本文实例讲述了Java基于正则表达式实现查找匹配的文本功能.分享给大家供大家参考,具体如下: REMatch.java: package reMatch; import java.util.regex ...

  10. java抢单功能_基于消息队列的高并发抢单功能实现方法与流程

    本发明涉及嵌入式软件中间件,具体涉及一种基于消息队列的高并发抢单功能实现方法. 背景技术: 中间件是一种独立的系统软件或服务程序,分布式应用系统借助这种软件在不同的技术之间共享资源,管理计算资源和网络 ...

最新文章

  1. 久坐 缺乏运动 消化能力 会减弱
  2. Hive简单案例WordCount
  3. 程序包com.sun.image.codec.jpeg.JPEGCo不存在解决办法
  4. 「Python」pandas入门教程
  5. 吴恩达深度学习一:神经网络
  6. ASP.NET MVC 最佳开发实践(1)
  7. aix安装bff_##aix5.3升级到高版本后,安装低BFF文件的问题
  8. 《自然》:这家中国AI公司的计划,超越了所有对手
  9. ListView乱谈之ListView的布局
  10. 微信小程序选择市,区县
  11. 微机原理-8086CPU
  12. 借助科技的力量,让物联网更好的服务鱼虾养殖业
  13. 一个IP到底值多少钱
  14. 【大数据离线开发】1、大数据准备环境之Linux配置
  15. 索尔维会议记录软件测试,科学史上的今天:10/30|索尔维会议创立,史上最强科学梦幻明星队...
  16. 华丽的设计,20个免费的图标字体
  17. 【038】基于51单片机的土壤湿度自动浇花系统Proteus仿真设计
  18. 《C语言入门》简单回文序列问题求解
  19. C语言猜数字游戏(详解)
  20. 微博付费打赏架构:一个社交场景下准金融项目开发和实践

热门文章

  1. 二维空间:点到直线距离的计算
  2. 应用加速,数字人民币接入多地交通出行场景 | 产业区块链发展周报
  3. weblogic错误页面
  4. 中国电信中兴 B860AV 1.1-T线刷及卡刷固件和刷机教程.zip
  5. 【四足机器人那些事儿】MiniCheetah中的MPC控制
  6. 一款,整合百度翻译api跟有道翻译api的翻译君
  7. 程序员工作交接文档怎么写_IT交接事项.doc
  8. 定时器实现原理——时间轮
  9. 电力载波通信了解笔记
  10. 异步通信在生活中的例子_通信技术在日常生活中的作用