下载试用版
截屏是一种快速而简便的获取和共享信息的方法。虽然Windows提供了一个剪切工具,但它只能捕获和保存图像。使用此代码,您可以保存图像以及图像中的文本。可以为该文本建立索引,以便以后可以使用Windows内置搜索找到信息。
使用.NET Clipboard Class,开发人员可以轻松地使用GetImageMethod来检索存储在剪贴板中的图像。 从剪贴板中获得图像后,请使用LEADTOOLS通过ConvertFromImage方法将图像转换为RasterImage。 现在,您可以使用LEADTOOLS OCR SDK将新的RasterImage转换为可搜索的PDF。
代码
.NET代码从剪贴板获取图像
public Image GetClipboardImage(){ Image returnImage = null; if (Clipboard.ContainsImage()) { returnImage = Clipboard.GetImage(); } return returnImage;}
LEADTOOLS OCR代码可将剪贴板中的图像另存为可搜索的PDF
string outputPath = $@"C:Temp{textBox1.Text}.pdf";Image screenshot = GetClipboardImage();using (RasterImage image = RasterImageConverter.ConvertFromImage(screenshot, ConvertFromImageOptions.None)){ using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false)) { ocrEngine.Startup(codecs, null, null, null; // Create an OCR document using (IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument()) { // Add this image to the document IOcrPage ocrPage = ocrDocument.Pages.AddPage(image, null); // Auto-recognize the zones in the page ocrPage.AutoZone(null); // Recognize it and save it as a PDF file ocrPage.Recognize(null); ocrDocument.Save(outputPath, DocumentFormat.Pdf, null); } }}

相关内容推荐:
LEADTOOLS 使用教程>>>
包含OCR的产品有:LEADTOOLS Recognition Imaging Developer Toolkit、LEADTOOLS Document Imaging Suite Developer Toolkit、LEADTOOLS OCR Module – LEAD Engine、LEADTOOLS OCR Module – OmniPage Engine、LEADTOOLS ICR Module – OmniPage Engine、LEADTOOLS OCR Module – OmniPage Engine with Additional Languages,想要了解更多产品详情请点击【咨询在线客服】

标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!