1.开发在java中的集成需要java开发环境,并且引入jar包(厂商提供的jar包):com.abbyy.FREngine.jar

2.java集成的代码展示(并且实现了生成pdf每页大小一致功能,对汉字的支持,生成pdf为双层pdf可以进行复制):

package com.iboyaa.ocr;import com.abbyy.FREngine.*;
import com.iboyaa.model.Material;
import com.iboyaa.ocr.BatchProcessing.ImageSourceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;public class OcrUtil {private final static Logger logger = LoggerFactory.getLogger(OcrUtil.class);private IEngine engine = null;public static void main( String[] args ) {long start = System.currentTimeMillis();try {Material material =new Material();material.setFolderOnly("1535702091255");//String folderdOly ="1535532134900";OcrUtil ocrUtil = new OcrUtil();ocrUtil.Run(material);} catch( Exception ex ) {displayMessage( ex.getMessage() );}System.out.println(System.currentTimeMillis()-start);}private static void displayMessage( String message ) {System.out.println( message );logger.info(message);}public void Run(String folderdOly) throws Exception {// Load ABBYY FineReader EngineloadEngine();try{// Process with ABBYY FineReader EngineprocessWithEngine(folderdOly);} finally {// Unload ABBYY FineReader EngineunloadEngine();}}public  void Run(Material material) throws Exception {// Load ABBYY FineReader EngineloadEngine();try{// Process with ABBYY FineReader EngineprocessWithEngine(material);} finally {// Unload ABBYY FineReader EngineunloadEngine();}}private void processWithEngine(Material material) {try {// Setup FREnginesetupFREngine();// Batch processingbatchProcessing(material);} catch( Exception ex ) {displayMessage( ex.getMessage() );}}private void processWithEngine(String folderdOly) {try {// Setup FREnginesetupFREngine();// Batch processingbatchProcessing(folderdOly);} catch( Exception ex ) {displayMessage( ex.getMessage() );}}//保证生成的pdf中内容大小一致private void batchProcessing(Material material) throws Exception {System.out.println("-------------");String folderdOly =material.getFolderOnly();SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");//设置日期格式String dateName ="";if (folderdOly!=null&&!"".equals(folderdOly)){Date date =new Date(Long.parseLong(folderdOly));dateName = df.format(date);// new Date()为获取当前系统时间,也可使用当前时间戳}else{Date date =new Date(System.currentTimeMillis());dateName = df.format(date);// new Date()为获取当前系统时间,也可使用当前时间戳}//图片路径文件夹String sourceFolder = CombinePaths( SamplesConfig.GetSamplesFolder(), "saomiaoImg/"+dateName+"/"+folderdOly+"/img");//pdf生成路径文件夹String resultFolder = CombinePaths( SamplesConfig.GetSamplesFolder(), "saomiaoImg/"+dateName+"/"+folderdOly );// Check source folder existenceif( !isDirectoryExist( sourceFolder ) ) {throw new Exception( "Cannot find " + sourceFolder );}// Create result folder if it doesn't existcreateDirectory( resultFolder );// Create ImageSourceImpl for accessing to images files in source folderImageSourceImpl imageSource = new ImageSourceImpl( sourceFolder );if( imageSource.IsEmpty() ) {throw new Exception( "No images in specified folder." );}IBatchProcessor batchProcessor = engine.CreateBatchProcessor();// Obtain recognized pages and export them to RTF format// Create documentIFRDocument document = engine.CreateFRDocument();//对图片设置大小一样IPrepareImageMode pim = engine.CreatePrepareImageMode();pim.setCorrectSkew(false);// pim.setCorrectSkewMode(CorrectSkewModeEnum.CSM_CorrectSkewByHorizontalLines.getValue() + CorrectSkewModeEnum.CSM_CorrectSkewByVerticalText.getValue());pim.setAutoOverwriteResolution(false);pim.setOverwriteResolution(true);// Start batch processor for specified image sourcebatchProcessor.Start( imageSource, null, pim, null, null );IFRPage page = batchProcessor.GetNextProcessedPage();try {int num = 0;while( page != null ) {num++;// Synthesize page before exportpage.Synthesize(null);// Export page to file with the same name and pdf extensionString resultFilePath = page.getSourceImagePath();displayMessage( "Process..." +resultFilePath+"-----");document.AddImageFile(resultFilePath, pim, null);page = batchProcessor.GetNextProcessedPage();}//编码,汉字IRecognizerParams  rp = engine.CreateRecognizerParams();rp.setLowResolutionMode(true);rp.SetPredefinedTextLanguage("English, ChinesePRC");IObjectsExtractionParams oep = engine.CreateObjectsExtractionParams();oep.setDetectTextOnPictures(true);oep.setEnableAggressiveTextExtraction(true);IPageAnalysisParams pap = engine.CreatePageAnalysisParams();pap.setEnableTextExtractionMode(true);IPagePreprocessingParams ppp = engine.CreatePagePreprocessingParams();ppp.setCorrectOrientation(true);IDocumentProcessingParams dpp = engine.CreateDocumentProcessingParams();dpp.getPageProcessingParams().setRecognizerParams(rp);dpp.getPageProcessingParams().setObjectsExtractionParams(oep);dpp.getPageProcessingParams().setPageAnalysisParams(pap);dpp.getPageProcessingParams().setPagePreprocessingParams(ppp);// Process documentdisplayMessage( "Process..." );document.Process( dpp );IPDFExportParams pdfParams = engine.CreatePDFExportParams();//快速pdfParams.setScenario(PDFExportScenarioEnum.PES_MaxSpeed);//均衡//pdfParams.setScenario( PDFExportScenarioEnum.PES_Balanced );pdfParams.getPDFFeatures().getPaperSizeParams().setPaperSizeMode(PaperSizeModeEnum.PSM_ImageSize);
//            pdfParams.getPDFFeatures().getPaperSizeParams().setPaperSizeMode(PaperSizeModeEnum.PSM_UserDefined);
//            pdfParams.getPDFFeatures().getPaperSizeParams().setPaperWidth(11909);
//            pdfParams.getPDFFeatures().getPaperSizeParams().setPaperHeight(16834);String pdfExportPath =resultFolder + "/"+folderdOly+".pdf";document.Export( pdfExportPath, FileExportFormatEnum.FEF_PDF, pdfParams );material.setPage(num);material.setAddress("/saomiaoImg/"+dateName+"/"+folderdOly+ "/"+folderdOly+".pdf");}catch( Exception ex ) {displayMessage( ex.getMessage() );} finally {// Close documentdocument.Close();}}private void setupFREngine() {displayMessage( "Loading predefined profile..." );engine.LoadPredefinedProfile( "DocumentConversion_Accuracy" );// 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",//   "BusinessCardsProcessing",//   "EngineeringDrawingsProcessing",//   "Version9Compatibility",//   "Default"}public static String CombinePaths( String path1, String path2 ) {File file1 = new File( path1 );File file2 = new File( file1, path2 );return file2.getPath();}private static boolean isDirectoryExist( String path ) {File file = new File( path );return file.exists();}private static void createDirectory( String path ) {File file = new File( path );if( !file.exists() ) {file.mkdir();}}//无法保证生成的pdf中内容大小一致private void batchProcessing(String folderdOly) throws Exception {SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");//设置日期格式String dateName ="";if (folderdOly!=null&&!"".equals(folderdOly)){Date date =new Date(Long.parseLong(folderdOly));dateName = df.format(date);// new Date()为获取当前系统时间,也可使用当前时间戳}else{Date date =new Date(System.currentTimeMillis());dateName = df.format(date);// new Date()为获取当前系统时间,也可使用当前时间戳}//图片路径文件夹String sourceFolder = CombinePaths( SamplesConfig.GetSamplesFolder(), "saomiaoImg/"+dateName+"/"+folderdOly+"/img");//pdf生成路径文件夹String resultFolder = CombinePaths( SamplesConfig.GetSamplesFolder(), "saomiaoImg/"+dateName+"/"+folderdOly );// Check source folder existenceif( !isDirectoryExist( sourceFolder ) ) {throw new Exception( "Cannot find " + sourceFolder );}createDirectory( resultFolder );// Create ImageSourceImpl for accessing to images files in source folderImageSourceImpl imageSource = new ImageSourceImpl( sourceFolder );if( imageSource.IsEmpty() ) {throw new Exception( "No images in specified folder." );}IBatchProcessor batchProcessor = engine.CreateBatchProcessor();// Obtain recognized pages and export them to RTF format// Create documentIFRDocument document = engine.CreateFRDocument();IPrepareImageMode pim = engine.CreatePrepareImageMode();pim.setCorrectSkew(true);pim.setCorrectSkewMode(CorrectSkewModeEnum.CSM_CorrectSkewByHorizontalLines.getValue() + CorrectSkewModeEnum.CSM_CorrectSkewByVerticalText.getValue());pim.setAutoOverwriteResolution(true);// Start batch processor for specified image sourcebatchProcessor.Start( imageSource, null, pim, null, null );IFRPage page = batchProcessor.GetNextProcessedPage();try {while( page != null ) {// Synthesize page before exportpage.Synthesize(null);// Export page to file with the same name and pdf extensionString resultFilePath = page.getSourceImagePath();displayMessage( "Process..." +resultFilePath+"-----");document.AddImageFile(resultFilePath, null, null);page = batchProcessor.GetNextProcessedPage();}IRecognizerParams  rp = engine.CreateRecognizerParams();rp.setLowResolutionMode(true);rp.SetPredefinedTextLanguage("English, ChinesePRC");IObjectsExtractionParams oep = engine.CreateObjectsExtractionParams();oep.setDetectTextOnPictures(true);oep.setEnableAggressiveTextExtraction(true);IPageAnalysisParams pap = engine.CreatePageAnalysisParams();pap.setEnableTextExtractionMode(true);IPagePreprocessingParams ppp = engine.CreatePagePreprocessingParams();ppp.setCorrectOrientation(true);IDocumentProcessingParams dpp = engine.CreateDocumentProcessingParams();dpp.getPageProcessingParams().setRecognizerParams(rp);dpp.getPageProcessingParams().setObjectsExtractionParams(oep);dpp.getPageProcessingParams().setPageAnalysisParams(pap);dpp.getPageProcessingParams().setPagePreprocessingParams(ppp);// Process documentdisplayMessage( "Process..." );document.Process( dpp );// Save resultsdisplayMessage( "Saving results..." );//           Save results to rtf with default parameters
//          String rtfExportPath = resultFolder+ "\\Demo.rtf";
//          document.Export( rtfExportPath, FileExportFormatEnum.FEF_RTF, null );
//
//          // Save results to pdf using 'balanced' scenarioIPDFExportParams pdfParams = engine.CreatePDFExportParams();pdfParams.setScenario( PDFExportScenarioEnum.PES_Balanced );String pdfExportPath =resultFolder + "\\"+folderdOly+".pdf";document.Export( pdfExportPath, FileExportFormatEnum.FEF_PDF, pdfParams );}catch( Exception ex ) {displayMessage( ex.getMessage() );} finally {// Close documentdocument.Close();}}private void loadEngine() throws Exception {displayMessage( "Initializing Engine..." );engine = Engine.GetEngineObject( SamplesConfig.GetDllFolder(), SamplesConfig.GetDeveloperSN() );
//        IMultiProcessingParams multiProcessingParams=engine.getMultiProcessingParams();
//        multiProcessingParams.set}private void unloadEngine() throws Exception {displayMessage( "Deinitializing Engine..." );engine = null;Engine.DeinitializeEngine();}
}

ABBYY OCR客开demo相关推荐

  1. U9ERP系统无法分割料品领料功能客开开发

    U9ERP系统无法分割料品领料功能客开开发,把思路分享出来给哪些U9开发人员参考 QQ:271510994

  2. 【NC65】主子表单据按照单表结构展现 节点客开

    需求描述: 需要将[采购入库]按照[采购订单关闭]节点的形式展现数据. 客开思路: 功能注册增加功能节点,(40080603)勾选启用. 菜单注册增加 菜单 并关联 功能节点(40080603). 初 ...

  3. ABBYY OCR SDK免费试用了!

    ABBYY OCR SDK是高度精确的光学字符识别工具包,之前只提供给企业和成像专家. 现在可供大家通过web API从云端获得该产品,并体验免费开发.无限测试,以及支付使用该产品的直接费用(不含其它 ...

  4. 9月19日云栖精选夜读:阿里云MVP Meetup极客开跑_与MVP一起玩转云计算

    原文地址 阿里云MVP Meetup不只是为开发者.云计算爱好者提供了一个交流的平台,同时也为MVP提供了一个展示自我的机会.让更多开发者零距离走进阿里云MVP,与MVP共同参与云计算的建设. 热点热 ...

  5. ABBYY OCR的客开包安装流程

    第一步:安装加密狗驱动 1.插入加密狗,安装加密狗驱动 ,(iKeyAll_v4_2_0_5_Dec2013_1032文件夹下):安装成功如下: 2.安装ABBYY License Manager:双 ...

  6. 很多人都不知道,其实博客园给我们博客开了二级域名

    如题.一直都在邮件签名里写自己的博客地址为: http://www.cnblogs.com/datacool:直到有天突然发现使用:http://datacool.cnblogs.com也可以访问.不 ...

  7. Uliweb多人博客教程demo站点

    2019独角兽企业重金招聘Python工程师标准>>> 为了让大家有一个更直观的学习教程做出来的效果,我昨天先是在openshift上创建了 demo-uliweb.rhcloud. ...

  8. 博客开园了~~~~~~

    久闻博客园大名,今天我终于进来了,我要在园子里种些东西.留下足迹. 转载于:https://www.cnblogs.com/googlegis/archive/2009/04/10/2979073.h ...

  9. MXS - CSDN 博客开写啦!

    游荡在各个ASP.NET论坛很久啦! 在就在CSDN注册账号了,但是一直没有关心过博客这边! 以前自己找东西用都是看别人的博客-CSDN的,现在我也好好写一写,给别人一些资料! 感谢那些一直为我们AS ...

最新文章

  1. 企业微信发送企业红包java_发放企业红包
  2. 谷歌浏览器安装POSTMAN
  3. 心形尺寸比例图解_0元图解建筑史-05 | 中国木构建筑的特征与详部演变(2)——斗栱、厅堂殿堂...
  4. python修改文件后缀_python实现遍历文件夹修改文件后缀
  5. query row php,php – 如何在Codeigniter上使用$query- row获取类对象
  6. 到底什么才是人生最大的投资
  7. 服务器虚拟化svc,SVC的虚拟化变革
  8. Spring Aop 切点表达式
  9. bug的一生:如何体现测试专业度?
  10. java stringbuffer原理_深入理解String, StringBuffer, StringBuilder的区别(基于JDK1.8)
  11. C语言实例:斐波那契数列
  12. 基于富士通编译器Softune的堆栈、变量、常量理解
  13. 使用jeDate日期控件
  14. win10安装UOS双系统过程
  15. 移动产品设计书籍推荐
  16. Image Caption 常用评价指标
  17. github上如何下载单个文件
  18. python序号,python排序、得出序号各类方法大全 numpy pandas
  19. 播布客老顽童MySQL DBA培训目录
  20. FFmpeg入门详解之121:颜色空间转换RGB和YUV的原理与实战

热门文章

  1. 面经--前程无忧(前锦网络)
  2. OPC UA协议网关
  3. 文件储存树的理解(ISAM 和 B+Tree)
  4. Django! 褪去浮华
  5. javaweb基础打卡12
  6. 手机计算机软件删除了怎么恢复,电脑的程序软件不小心被删掉,该如何恢复?...
  7. 聚名:拼音域名选择和投资的技巧
  8. 鱼眼参数的数值计算优化方法
  9. 【Mac+Deepin系统】两台主机一个显示器如何切换显示?
  10. 干货|app自动化测试之Appium 原理 与 JsonWP 协议分析