找回密码
 立即注册

QQ登录

只需一步,快速开始

caihuamao520

注册会员

9

主题

34

帖子

107

积分

注册会员

积分
107
caihuamao520
注册会员   /  发表于:2016-11-8 23:11  /   查看:11691  /  回复:25
我笔记本电脑配置有4GB 的内存 i3的CPU 这样配置的电脑 代码在运行过程中 10页以内的TIF文件转换PDF文件基本都正常,当出现20页以上的时候 PDF文档有就会抛出异常,提示 Not enough memory for this memory Operation。(前提是我的TIF文件是300分辨率的,幅面都是在A3左右,我是把多个的单页的TIF文件转换成一个PDF文件)。

                                IOcrEngine _ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Professional, false);                                 
                                // 启动OCR引擎
                                _ocrEngine.Startup(null, null, null, Path.Combine(Application.StartupPath, "OcrProfessionalRuntime"));                                
                                // 创建文档
                                IOcrDocument _ocrDocument = _ocrEngine.DocumentManager.CreateDocument();
                                _ocrEngine.LanguageManager.EnableLanguages(new string[] { "zh-Hans", "en" });
                                // 启用拼写检查系统,并将英文设置为拼写语言
                                _ocrEngine.SpellCheckManager.SpellCheckEngine = OcrSpellCheckEngine.Native;
                                _ocrEngine.SpellCheckManager.SpellLanguage = "en";
                                foreach (string fileName in ArrFilepath)
                                {
                                    Application.DoEvents();                                   
                                    if (!File.Exists(fileName)) return;
                                    _ocrDocument.Pages.AddPage(fileName, null);                                    
                                }
                                Application.DoEvents();                                
                                // 识别所有页面
                                // 注意,我们不需要调用AutoZone,引擎会检查页面是否被分区,若无,则会自动分区
                                _ocrDocument.Pages.Recognize(null);
                                PdfDocumentOptions pdfs = _ocrDocument.DocumentWriterInstance.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions;
                                pdfs.ImageOverText = true;//图像与文字 双层PDF
                                pdfs.PageRestriction = DocumentPageRestriction.Relaxed;
                                switch (this.cbDocumntType.Text)
                                {
                                    case "PDF": pdfs.DocumentType = PdfDocumentType.Pdf; break;
                                    case "PDF/A": pdfs.DocumentType = PdfDocumentType.PdfA; break;
                                    case "PDF12": pdfs.DocumentType = PdfDocumentType.Pdf12; break;
                                    case "PDF13": pdfs.DocumentType = PdfDocumentType.Pdf13; break;
                                    case "PDF15": pdfs.DocumentType = PdfDocumentType.Pdf15; break;
                                    case "PDF16": pdfs.DocumentType = PdfDocumentType.Pdf16; break;
                                }
                                _ocrDocument.DocumentWriterInstance.SetOptions(DocumentFormat.Pdf, pdfs);
                                _ocrDocument.Save(strSavePDFPath, DocumentFormat.Pdf, null);
                                Application.DoEvents();
                                // 释放此文档
                                _ocrDocument.Dispose();
                                // 关闭OCR引擎
                                _ocrEngine.Shutdown();
                                GC.Collect();



25 个回复

正序浏览
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2017-8-28 10:43:18
26#
回复 使用道具 举报
caihuamao520
注册会员   /  发表于:2017-8-28 09:34:03
25#
好 感谢
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2017-7-26 12:07:48
24#
和厂商沟通过了,目前暂无其他的解决办法,已经作为bug反馈给厂商,后续有新的情况我会及时反馈的。
回复 使用道具 举报
caihuamao520
注册会员   /  发表于:2017-7-25 21:37:05
23#
好的
回复 使用道具 举报
caihuamao520
注册会员   /  发表于:2017-7-25 21:37:01
22#
好的
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2017-7-11 10:10:01
21#
嗯,这个可能需要咨询厂商那边一些参数的设置,有消息我就反馈你
回复 使用道具 举报
caihuamao520
注册会员   /  发表于:2017-7-10 17:54:31
20#
好的
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2017-7-10 10:10:54
19#
了解了,理解错你的意思了,我以为说是程序报错了,我再验证下这个问题
回复 使用道具 举报
caihuamao520
注册会员   /  发表于:2017-7-7 15:32:55
18#
注意看 软件配置 这行字的选择区域块(蓝色部分)
回复 使用道具 举报
123下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部