与其他组件比较 IronOCR 和 PDFTRON OCR 之间的比较 Kannapat Udonpant 已更新:七月 28, 2025 下载 IronOCR NuGet 下载 DLL 下载 Windows 安装程序 免费试用 法学硕士副本 法学硕士副本 将页面复制为 Markdown 格式,用于 LLMs 在 ChatGPT 中打开 向 ChatGPT 咨询此页面 在双子座打开 向 Gemini 询问此页面 在双子座打开 向 Gemini 询问此页面 打开困惑 向 Perplexity 询问有关此页面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 复制链接 电子邮件文章 OCR 代表"光学字符识别"。 这是将纸质文档或图像转换为可读文本的过程。 存在多种方法可以执行此操作,例如通过扫描或通过键盘手动输入。 这样做是为了将任何扫描文件和 PDF 转换为其原始文本格式。 这一过程在文档因损坏而无法人工转录但可以通过 OCR 软件扫描和解释的刑事案件中证明是非常宝贵的。 随着技术的发展和数字工具的广泛采用,OCR 也被应用于其他领域,例如 Google Docs 等应用中的文档转换,以及学术界和商业世界中。 OCR 有两种主要类型,即"静态"和"动态"。 最常见的类型是静态 OCR,其中一次扫描整个文档。 另一方面,动态 OCR 一次扫描一行,并且可以处理更复杂的布局,如表格数据。 本文将讨论两种最流行的 OCR 和 PDF 应用程序及文档库之间的比较。 这些是: PDFTron OCR IronOCR 1.0 介绍 1.1 PDFTron OCR 介绍和功能 要使用 PDFTron SDK 的 OCR,我们必须安装一个单独的 OCR 模块插件实用程序。 这有助于 SDK 从文档中检测文本。 它可以使文本可选择和可搜索。 PDFTron SDK 支持多达 100 种语言。 PDFTron OCR 引擎由 Tesseract 的开源 LSTM 神经网络支持。 PDFTron OCR 支持多种图像格式类型的文本检测。 仅包含栅格图像的 PDF 文件也可用于 OCR,其输出质量取决于输入图像。 最适合 OCR 的图像是 300 DPI 分辨率的灰度图像。 PDFTron OCR 的功能 使印刷文档中的图像可搜索。 将简单的 PDF 转换为可搜索的 PDF。 从商业文档中检测重要信息。 使图书扫描更容易。 从车辆图像中检测车辆号码。 帮助视障用户。 使用 OCR 在多个文档中进行数据录入变得简单。 轻松将名片中的信息传输到联系人数据列表中。 1.2 IronOCR — 简介和特性 Iron Software 为开发人员提供 IronOCR for .NET,以读取 .NET 应用程序和网站中照片和 PDF 中的文本内容。 该软件有助于扫描照片以获取文本和条形码,支持多种全球语言,并以纯文本或结构化数据输出。 Iron Software 的 OCR 库可用于 Web、控制台、MVC 和多个 .NET 桌面应用程序。 在商业部署的情况下,购买的许可证将提供开发团队的直接支持。 IronOCR 使用最新的 Tesseract 5 引擎,可以从任何 PDF 格式或读取文本、二维码和条形码。 将此库添加到桌面、Web 应用程序和控制台中确保快速集成。 IronOCR 支持 125 种国际语言。 它还支持自定义语言和词汇列表。 IronOCR 可以读取超过 20 种条形码和二维码格式。 支持多页 GIF 和 TIFF 图像格式。 修正低质量扫描和图像。 支持多线程。 它可以同时执行一个或多个进程。 IronOCR 可以提供结构化数据输出到页面、段落、行、单词、字符等。 IronOCR 支持的操作系统包括 Windows、Linux、macOS 等。 2. 在Visual Studio中创建一个新项目 打开 Visual Studio 并找到文件菜单。 选择新项目,然后选择控制台应用程序。 要生成 PDF 文档,我们将在本文中使用控制台应用程序。 输入项目名称,并在相应的文本框中选择文件路径。 然后,点击创建按钮。 还可选择所需的.NET框架。 Visual Studio项目将现在生成所选应用程序的结构。 项目结构现在将由 Visual Studio 生成。 如果您选择了 Windows、控制台和 Web 应用程序,program.cs 文件将打开,您可以输入代码并构建/运行您的应用程序。 对于下一步,我们需要添加库来测试代码。 3.0 安装 3.1 安装 PDFtron OCR The PDFTron OCR installation is completed manually and can be downloaded as a zip from the given link. 解压并配置到项目中。 本指南将帮助您将 PDFTron 示例与集成的免费试用版的 PDFTron SDK 在 Windows 的 .NET Framework 应用程序中执行。 支持解决方案工程师和无限制试用版包含在免费试用中。 先决条件 Visual Studio: 确保您的安装中包含了 .NET 桌面开发 和 .NET Framework 4.5.1+ 开发工具 工作负载。 本指南将使用 Visual Studio 2017 和 PDFTron 的 C# .NET PDF 库 for Windows。 Download the library using this link, .NET PDF SDK Download. 初始设置 从.zip 文件中提取文件夹。本指南中使用 PDFNET_BASE 来选择您解压的文件夹路径。 // Set the base path where the extracted files are located PDFNET_BASE = "path/to/extraction/folder/PDFNetDotNet4/"; // Set the base path where the extracted files are located PDFNET_BASE = "path/to/extraction/folder/PDFNetDotNet4/"; ' Set the base path where the extracted files are located PDFNET_BASE = "path/to/extraction/folder/PDFNetDotNet4/" $vbLabelText $csharpLabel 运行示例 导航到提取内容的位置。 找到并进入 Samples 文件夹(PDFNET_BASE/Samples)。 此文件夹中包含 PDFTron SDK 支持的多个示例代码。 在 Visual Studio 中打开 Samples_20XX.sln。 为您的 Visual Studio 安装选择合适的版本。 Select the sample code and set it as the Startup Project for the solution. 运行项目。 集成到您的应用程序中 这被称为"PDFTron Hello World"应用程序。 如果您可以打开、保存和关闭 PDF 文档,那么集成其余的 PDFTron SDK 是很容易的。 在 Visual Studio 中,使用您喜欢的语言创建 .NET Framework 控制台应用程序项目。 您可以在 Visual C# 或 Visual Basic 类别下找到它们。 导航到您的项目文件夹。 默认情况下,路径应类似于:C:/Users/User_Name/source/repos/myApp 从 PDFNET_BASE 复制 Lib 文件夹到您的项目文件夹(这个文件夹将包含您的 .csproj 或 .vbproj 文件)。 在右侧找到解决方案资源管理器。右键单击引用,然后选择添加引用选项。 这将打开一个引用管理器对话框。 在对话框底部,选择浏览。 导航到复制到的 Lib 文件夹,以添加 PDFNetLoader.dll 到引用 此外,从 x86 文件夹添加合适版本的 PDFNet.dll 作为另一个引用(path/to/your/project/folder/Lib/PDFNet/x86/PDFNet.dll)。 这将确保应用程序在 32 位和 64 位操作系统上均可运行。 点击 PDFNet.dll。 确保将其复制本地属性设置为 False。 3.2 安装IronOCR IronOCR 库可以通过四种方式安装。 这些是: 使用 Visual Studio。 使用Visual Studio命令行。 从NuGet网站直接下载。 从 IronOCR 网站直接下载。 3.2.1 使用 Visual Studio Visual Studio软件提供了NuGet包管理器选项,可以将包直接安装到解决方案中。 截图演示了如何打开 NuGet 包管理器。 这将提供一个搜索框,在 NuGet 网站上显示包列表。在包管理器中,我们需要搜索关键字"IronOCR",如下截图所示: 从上图中可以看到相关的搜索结果列表。 要将包安装到解决方案中,我们必须选择所需的选项。 3.2.2 使用 Visual Studio 命令行 在 Visual Studio 中:转到工具 -> NuGet 包管理器 -> 包管理器控制台 将接下来的代码片段输入到包管理器控制台选项卡。 Install-Package IronOcr 包现在将直接安装到当前项目中,然后可以使用。 3.2.3 从 NuGet 网站直接下载 对于第三种方法,我们可以直接从网站下载 NuGet 包 转到此链接。 从右侧菜单中,确保选择下载包选项。 双击下载后的包。 它将自动安装。 接下来,重新加载解决方案并开始在项目中使用它。 3.2.4 从 IronOCR 网站直接下载 您可以通过点击此链接直接从网站下载最新包。 按照提供的说明将包添加到项目中,一旦下载了最新包。 从解决方案窗口中右键点击项目。 选择选项引用来浏览下载的引用的位置。 然后,单击确定以添加引用。 4.0 OCR 图像 IronOCR 和 PDFtron OCR 都有将图像转换为文本搜索的 OCR 技术。 4.1 使用 PDFTron 将 PDF 转换为 DOCX、DOC、HTML、SVG、TIFF、PNG、JPEG、XPS、EPUB、TXT 和许多其他格式。 // Create a new PDF document PDFDoc doc = new PDFDoc("sample.pdf"); // Convert PDF document to SVG Convert.ToSvg(doc, "output.svg"); // Convert PDF document to XPS Convert.ToXps("sample.pdf", "output.xps"); // Convert PDF document to multipage TIFF Convert.TiffOutputOptions tiff_options = new Convert.TiffOutputOptions(); tiff_options.SetDPI(200); tiff_options.SetDither(true); tiff_options.SetMono(true); Convert.ToTiff("sample.pdf", "output.tiff", tiff_options); // Convert PDF to XOD Convert.ToXod("sample.pdf", "output.xod"); // Convert PDF to HTML Convert.ToHtml("sample.pdf", "output.html"); // Create a new PDF document PDFDoc doc = new PDFDoc("sample.pdf"); // Convert PDF document to SVG Convert.ToSvg(doc, "output.svg"); // Convert PDF document to XPS Convert.ToXps("sample.pdf", "output.xps"); // Convert PDF document to multipage TIFF Convert.TiffOutputOptions tiff_options = new Convert.TiffOutputOptions(); tiff_options.SetDPI(200); tiff_options.SetDither(true); tiff_options.SetMono(true); Convert.ToTiff("sample.pdf", "output.tiff", tiff_options); // Convert PDF to XOD Convert.ToXod("sample.pdf", "output.xod"); // Convert PDF to HTML Convert.ToHtml("sample.pdf", "output.html"); ' Create a new PDF document Dim doc As New PDFDoc("sample.pdf") ' Convert PDF document to SVG Convert.ToSvg(doc, "output.svg") ' Convert PDF document to XPS Convert.ToXps("sample.pdf", "output.xps") ' Convert PDF document to multipage TIFF Dim tiff_options As New Convert.TiffOutputOptions() tiff_options.SetDPI(200) tiff_options.SetDither(True) tiff_options.SetMono(True) Convert.ToTiff("sample.pdf", "output.tiff", tiff_options) ' Convert PDF to XOD Convert.ToXod("sample.pdf", "output.xod") ' Convert PDF to HTML Convert.ToHtml("sample.pdf", "output.html") $vbLabelText $csharpLabel 4.2 使用IronOCR // Create an IronTesseract object var Ocr = new IronTesseract(); Ocr.Language = OcrLanguage.EnglishBest; Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5; using (var Input = new OcrInput()) { // Add an image for OCR Input.AddImage(@"3.png"); // Read the text from the image var Result = Ocr.Read(Input); // Print the text to the console Console.WriteLine(Result.Text); Console.ReadKey(); } // Create an IronTesseract object var Ocr = new IronTesseract(); Ocr.Language = OcrLanguage.EnglishBest; Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5; using (var Input = new OcrInput()) { // Add an image for OCR Input.AddImage(@"3.png"); // Read the text from the image var Result = Ocr.Read(Input); // Print the text to the console Console.WriteLine(Result.Text); Console.ReadKey(); } ' Create an IronTesseract object Dim Ocr = New IronTesseract() Ocr.Language = OcrLanguage.EnglishBest Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5 Using Input = New OcrInput() ' Add an image for OCR Input.AddImage("3.png") ' Read the text from the image Dim Result = Ocr.Read(Input) ' Print the text to the console Console.WriteLine(Result.Text) Console.ReadKey() End Using $vbLabelText $csharpLabel 以上示范的是利用 Tesseract 5 API 将图像文件转换为文本的过程。 以上代码行用于创建 Iron Tesseract 的对象。 此外,为了确保我们能够添加一个或多个图片文件,我们生成了一个 OcrInput 对象,该对象将需要可用的图片路径。 在 Iron Tesseract 对象中,"Read"函数可以用于通过解析图片文件来获取图像,并将生成的结果提取到 OCR 结果中。 它可以从照片中提取文本并将其转换为字符串。 Tesseract 可以使用"AddMultiFrameTiff"方法添加多帧图像执行此过程。 图像中的每一帧都会被读取,并被 Tesseract 库视为单独的页面。 在继续读取下一帧之前,会读取图像的每一帧,直到每一帧都成功扫描为止。 在此方法中仅支持 TIFF 图像格式。 数据成功转换为可编辑文本的情况显示在上面的图像中,这是 IronOCR 精度的结果。 5.0 OCR PDF 文件 IronOCR 和 PDFTron OCR 将 PDF 文件转换为可编辑文本。 PDFTron OCR 为用户提供保存页面、编辑图像、识别页面等选项。此外,它还可以 提供保存选项,如文档、文本、HTML格式等。IronOCR 也允许我们将转换后的 OCR 文件保存为 HTML、文本、PDF 等。 5.1 使用 PDFTron OCR 完整示例代码展示了如何使用 PDFTron OCR 进行 PDF、XPS、EMF、SVG、TIFF、PNG、JPEG 和其他图像格式之间的直接高质量转换。 // Copyright (c) 2001-2021 by PDFTron Systems Inc. All Rights Reserved. using System; using pdftron; using pdftron.Common; using pdftron.Filters; using pdftron.SDF; using pdftron.PDF; // This code demonstrates conversion of documents to formats such as SVG, PDF, EMF, or XPS. namespace ConvertTestCS { class Testfile { public string inputFile, outputFile; public bool requiresWindowsPlatform; public Testfile(string inFile, string outFile, bool requiresWindowsPlatform_) { inputFile = inFile; outputFile = outFile; requiresWindowsPlatform = requiresWindowsPlatform_; } }; class Class1 { private static pdftron.PDFNetLoader pdfNetLoader = pdftron.PDFNetLoader.Instance(); static Class1() {} // Relative paths to the input and output folders. const string inputPath = "../../../../TestFiles/"; const string outputPath = "../../../../TestFiles/Output/"; static bool ConvertSpecificFormats() { bool err = false; try { using (PDFDoc pdfdoc = new PDFDoc()) { // Convert from XPS to PDF Console.WriteLine("Converting from XPS"); pdftron.PDF.Convert.FromXps(pdfdoc, inputPath + "simple-xps.xps"); pdfdoc.Save(outputPath + "xps2pdf v2.pdf", SDFDoc.SaveOptions.e_remove_unused); Console.WriteLine("Saved xps2pdf v2.pdf"); } } catch (PDFNetException e) { Console.WriteLine(e.Message); err = true; } // Other format conversions... return err; } static Boolean ConvertToPdfFromFile() { System.Collections.ArrayList testfiles = new System.Collections.ArrayList(); testfiles.Add(new ConvertTestCS.Testfile("simple-word_2007.docx", "docx2pdf.pdf", false)); // Add other test files... bool err = false; foreach (Testfile file in testfiles) { try { using (pdftron.PDF.PDFDoc pdfdoc = new PDFDoc()) { // Conditions and conversions... pdftron.PDF.Convert.ToPdf(pdfdoc, inputPath + file.inputFile); pdfdoc.Save(outputPath + file.outputFile, SDFDoc.SaveOptions.e_linearized); Console.WriteLine("Converted file: " + file.inputFile); Console.WriteLine("to: " + file.outputFile); } } // Catch exceptions... } return err; } static void Main(string [] args) { PDFNet.Initialize(PDFTronLicense.Key); bool err = false; err = ConvertToPdfFromFile(); if (err) { Console.WriteLine("ConvertFile failed"); } else { Console.WriteLine("ConvertFile succeeded"); } err = ConvertSpecificFormats(); if (err) { Console.WriteLine("ConvertSpecificFormats failed"); } else { Console.WriteLine("ConvertSpecificFormats succeeded"); } // Finalization... PDFNet.Terminate(); Console.WriteLine("Done."); } } } // Copyright (c) 2001-2021 by PDFTron Systems Inc. All Rights Reserved. using System; using pdftron; using pdftron.Common; using pdftron.Filters; using pdftron.SDF; using pdftron.PDF; // This code demonstrates conversion of documents to formats such as SVG, PDF, EMF, or XPS. namespace ConvertTestCS { class Testfile { public string inputFile, outputFile; public bool requiresWindowsPlatform; public Testfile(string inFile, string outFile, bool requiresWindowsPlatform_) { inputFile = inFile; outputFile = outFile; requiresWindowsPlatform = requiresWindowsPlatform_; } }; class Class1 { private static pdftron.PDFNetLoader pdfNetLoader = pdftron.PDFNetLoader.Instance(); static Class1() {} // Relative paths to the input and output folders. const string inputPath = "../../../../TestFiles/"; const string outputPath = "../../../../TestFiles/Output/"; static bool ConvertSpecificFormats() { bool err = false; try { using (PDFDoc pdfdoc = new PDFDoc()) { // Convert from XPS to PDF Console.WriteLine("Converting from XPS"); pdftron.PDF.Convert.FromXps(pdfdoc, inputPath + "simple-xps.xps"); pdfdoc.Save(outputPath + "xps2pdf v2.pdf", SDFDoc.SaveOptions.e_remove_unused); Console.WriteLine("Saved xps2pdf v2.pdf"); } } catch (PDFNetException e) { Console.WriteLine(e.Message); err = true; } // Other format conversions... return err; } static Boolean ConvertToPdfFromFile() { System.Collections.ArrayList testfiles = new System.Collections.ArrayList(); testfiles.Add(new ConvertTestCS.Testfile("simple-word_2007.docx", "docx2pdf.pdf", false)); // Add other test files... bool err = false; foreach (Testfile file in testfiles) { try { using (pdftron.PDF.PDFDoc pdfdoc = new PDFDoc()) { // Conditions and conversions... pdftron.PDF.Convert.ToPdf(pdfdoc, inputPath + file.inputFile); pdfdoc.Save(outputPath + file.outputFile, SDFDoc.SaveOptions.e_linearized); Console.WriteLine("Converted file: " + file.inputFile); Console.WriteLine("to: " + file.outputFile); } } // Catch exceptions... } return err; } static void Main(string [] args) { PDFNet.Initialize(PDFTronLicense.Key); bool err = false; err = ConvertToPdfFromFile(); if (err) { Console.WriteLine("ConvertFile failed"); } else { Console.WriteLine("ConvertFile succeeded"); } err = ConvertSpecificFormats(); if (err) { Console.WriteLine("ConvertSpecificFormats failed"); } else { Console.WriteLine("ConvertSpecificFormats succeeded"); } // Finalization... PDFNet.Terminate(); Console.WriteLine("Done."); } } } ' Copyright (c) 2001-2021 by PDFTron Systems Inc. All Rights Reserved. Imports System Imports pdftron Imports pdftron.Common Imports pdftron.Filters Imports pdftron.SDF Imports pdftron.PDF ' This code demonstrates conversion of documents to formats such as SVG, PDF, EMF, or XPS. Namespace ConvertTestCS Friend Class Testfile Public inputFile, outputFile As String Public requiresWindowsPlatform As Boolean Public Sub New(ByVal inFile As String, ByVal outFile As String, ByVal requiresWindowsPlatform_ As Boolean) inputFile = inFile outputFile = outFile requiresWindowsPlatform = requiresWindowsPlatform_ End Sub End Class Friend Class Class1 Private Shared pdfNetLoader As pdftron.PDFNetLoader = pdftron.PDFNetLoader.Instance() Shared Sub New() End Sub ' Relative paths to the input and output folders. Private Const inputPath As String = "../../../../TestFiles/" Private Const outputPath As String = "../../../../TestFiles/Output/" Private Shared Function ConvertSpecificFormats() As Boolean Dim err As Boolean = False Try Using pdfdoc As New PDFDoc() ' Convert from XPS to PDF Console.WriteLine("Converting from XPS") pdftron.PDF.Convert.FromXps(pdfdoc, inputPath & "simple-xps.xps") pdfdoc.Save(outputPath & "xps2pdf v2.pdf", SDFDoc.SaveOptions.e_remove_unused) Console.WriteLine("Saved xps2pdf v2.pdf") End Using Catch e As PDFNetException Console.WriteLine(e.Message) err = True End Try ' Other format conversions... Return err End Function Private Shared Function ConvertToPdfFromFile() As Boolean Dim testfiles As New System.Collections.ArrayList() testfiles.Add(New ConvertTestCS.Testfile("simple-word_2007.docx", "docx2pdf.pdf", False)) ' Add other test files... Dim err As Boolean = False For Each file As Testfile In testfiles Try Using pdfdoc As pdftron.PDF.PDFDoc = New PDFDoc() ' Conditions and conversions... pdftron.PDF.Convert.ToPdf(pdfdoc, inputPath & file.inputFile) pdfdoc.Save(outputPath & file.outputFile, SDFDoc.SaveOptions.e_linearized) Console.WriteLine("Converted file: " & file.inputFile) Console.WriteLine("to: " & file.outputFile) End Using End Try ' Catch exceptions... Next file Return err End Function Shared Sub Main(ByVal args() As String) PDFNet.Initialize(PDFTronLicense.Key) Dim err As Boolean = False err = ConvertToPdfFromFile() If err Then Console.WriteLine("ConvertFile failed") Else Console.WriteLine("ConvertFile succeeded") End If err = ConvertSpecificFormats() If err Then Console.WriteLine("ConvertSpecificFormats failed") Else Console.WriteLine("ConvertSpecificFormats succeeded") End If ' Finalization... PDFNet.Terminate() Console.WriteLine("Done.") End Sub End Class End Namespace $vbLabelText $csharpLabel 5.2 使用IronOCR 可以通过使用 OCRInput 函数完成 PDF 文件的管理。 Iron Tesseract 类将读取文档中的每一页。 然后将从页面中提取文本。 称为"AddPDF"的第二个函数将允许我们打开受保护的文档,并确保我们可以将 PDF 添加到我们的文档列表中(如果受保护,则提供密码)。 要打开受密码保护的 PDF 文档,请使用下面的代码片段: var Ocr = new IronTesseract(); // Configure nothing using (var Input = new OcrInput()) { // Add PDF with password Input.AddPdf("example.pdf", "password"); var Result = Ocr.Read(Input); Console.WriteLine(Result.Text); } var Ocr = new IronTesseract(); // Configure nothing using (var Input = new OcrInput()) { // Add PDF with password Input.AddPdf("example.pdf", "password"); var Result = Ocr.Read(Input); Console.WriteLine(Result.Text); } Dim Ocr = New IronTesseract() ' Configure nothing Using Input = New OcrInput() ' Add PDF with password Input.AddPdf("example.pdf", "password") Dim Result = Ocr.Read(Input) Console.WriteLine(Result.Text) End Using $vbLabelText $csharpLabel 通过利用"Addpdfpage"函数,可以实现从 PDF 文件中的一页读取和提取内容。 只需指定我们要从中提取文本的确切页码。 "AddPdfPage"将允许您从您指定的多页中提取文本。 IEnumerable 将允许您高效地指定多个页面。 您还必须包括文件的位置和扩展名。下面的代码片段演示了这一点: IEnumerable<int> numbers = new List<int> {2,8,10}; // Create an IronTesseract object var Ocr = new IronTesseract(); using (var Input = new OcrInput()) { // Single page Input.AddPdfPage("example.pdf",10); // Multiple pages Input.AddPdfPages("example.pdf", numbers); var Result = Ocr.Read(Input); Console.WriteLine(Result.Text); // Save result to a text file Result.SaveAsTextFile("ocrtext.txt"); } IEnumerable<int> numbers = new List<int> {2,8,10}; // Create an IronTesseract object var Ocr = new IronTesseract(); using (var Input = new OcrInput()) { // Single page Input.AddPdfPage("example.pdf",10); // Multiple pages Input.AddPdfPages("example.pdf", numbers); var Result = Ocr.Read(Input); Console.WriteLine(Result.Text); // Save result to a text file Result.SaveAsTextFile("ocrtext.txt"); } Dim numbers As IEnumerable(Of Integer) = New List(Of Integer) From {2, 8, 10} ' Create an IronTesseract object Dim Ocr = New IronTesseract() Using Input = New OcrInput() ' Single page Input.AddPdfPage("example.pdf",10) ' Multiple pages Input.AddPdfPages("example.pdf", numbers) Dim Result = Ocr.Read(Input) Console.WriteLine(Result.Text) ' Save result to a text file Result.SaveAsTextFile("ocrtext.txt") End Using $vbLabelText $csharpLabel 使用 SaveAsTextFile 函数将结果直接存储为文本文件格式,以便您可以直接下载该文件到输出目录路径中。 要将文件保存为 HTML 格式,请使用 SaveAsHocrFile。 6.1 使用 PDFTron 我们可以使用 PDFTron SDK 从 PDF 文件中提取图像,以及它们的位置信息和 DPI。 您可以不将 PDF 图像转换为位图,而是使用 elements.GetImageData()(在 PDF 数据提取代码示例中描述)直接提取未压缩/压缩的图像数据。 了解更多关于我们的 C# PDF 库和 PDF 解析和内容提取库。 6.2 使用IronOCR IronOCR提供了大量工具,允许您直接从扫描文档读取二维码和条形码。 下面的代码片段展示了如何从给定的图像或文档中扫描条形码。 // Create an IronTesseract object var Ocr = new IronTesseract(); Ocr.Language = OcrLanguage.EnglishBest; Ocr.Configuration.ReadBarCodes = true; Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5; using (var Input = new OcrInput()) { // Add an image with a barcode Input.AddImage("barcode.gif"); // Read the image var Result = Ocr.Read(Input); // Iterate over all barcodes found and display their values foreach (var Barcode in Result.Barcodes) { Console.WriteLine(Barcode.Value); } } // Create an IronTesseract object var Ocr = new IronTesseract(); Ocr.Language = OcrLanguage.EnglishBest; Ocr.Configuration.ReadBarCodes = true; Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5; using (var Input = new OcrInput()) { // Add an image with a barcode Input.AddImage("barcode.gif"); // Read the image var Result = Ocr.Read(Input); // Iterate over all barcodes found and display their values foreach (var Barcode in Result.Barcodes) { Console.WriteLine(Barcode.Value); } } ' Create an IronTesseract object Dim Ocr = New IronTesseract() Ocr.Language = OcrLanguage.EnglishBest Ocr.Configuration.ReadBarCodes = True Ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5 Using Input = New OcrInput() ' Add an image with a barcode Input.AddImage("barcode.gif") ' Read the image Dim Result = Ocr.Read(Input) ' Iterate over all barcodes found and display their values For Each Barcode In Result.Barcodes Console.WriteLine(Barcode.Value) Next Barcode End Using $vbLabelText $csharpLabel 以上代码帮助从给定的图像或 PDF 文档中读取条形码。 可以在同一图像或页面中同时读取多个条形码。 IronOCR 有一种独特的方法来读取条形码,Ocr.Configuration.ReadBarCodes。 数据在扫描输入后存储在名为 OCRResult 的对象中。 OCRResult 中的属性称为 Barcodes,将列出所有可用的条形码数据。 我们可以通过利用 for-each 循环获取与条形码详细信息相关的每个单独数据。在一个过程中完成两个操作- 条形码的扫描和读数。 还可以使用线程化选项支持,并且可以同时完成多个 OCR 过程。此外,IronOCR 可以从指定的区域识别一个精确的区域。 // Create an IronTesseract object var Ocr = new IronTesseract(); using (var Input = new OcrInput()) { // Define the content area to be scanned var ContentArea = new System.Drawing.Rectangle() { X = 215, Y = 1250, Height = 280, Width = 1335 }; // Add image specifying the content area Input.Add("document.png", ContentArea); // Perform OCR operation var Result = Ocr.Read(Input); // Print the text Console.WriteLine(Result.Text); } // Create an IronTesseract object var Ocr = new IronTesseract(); using (var Input = new OcrInput()) { // Define the content area to be scanned var ContentArea = new System.Drawing.Rectangle() { X = 215, Y = 1250, Height = 280, Width = 1335 }; // Add image specifying the content area Input.Add("document.png", ContentArea); // Perform OCR operation var Result = Ocr.Read(Input); // Print the text Console.WriteLine(Result.Text); } ' Create an IronTesseract object Dim Ocr = New IronTesseract() Using Input = New OcrInput() ' Define the content area to be scanned Dim ContentArea = New System.Drawing.Rectangle() With { .X = 215, .Y = 1250, .Height = 280, .Width = 1335 } ' Add image specifying the content area Input.Add("document.png", ContentArea) ' Perform OCR operation Dim Result = Ocr.Read(Input) ' Print the text Console.WriteLine(Result.Text) End Using $vbLabelText $csharpLabel 上面的代码片段演示了如何在一个特定区域执行 OCR。 您只需要指定 PDF/图像中的矩形区域,因为 IronOCR 的 Tesseract 引擎将有助于识别文本。 IronOCR 和 PDFtron OCR 许可证模式和定价 IronOCR 许可证模式和定价 30 天退款保证:一旦购买许可证,您将获得 30 天退款保证。 在 30 天内,如果您希望退还产品,您将收到退款。 轻松集成: IronOCR 的集成与任何项目和环境都是如此轻松,只需通过将其作为NuGet包添加的一行代码即可完成。 另一方面,另一种集成环境的方法是直接从网络下载。 永久许可证: 每项购买的许可证无需续订。 免费支持和产品更新:每个许可证都将获得来自产品背后的团队的直接支持,并附带一年免费产品更新。 随时可以购买延期。 即时许可证: 一旦收到付款,注册的许可证密钥将立即发送。 所有许可证都是永久性的,适用于开发、临时和生产环境。 基础许可证 1名开发人员 1个地点 1个项目 永久许可证 此套餐允许组织中的单个软件开发人员在一个地点利用 Iron Software。 Iron Software 可以在单一内部网络应用程序、Web 应用程序或桌面软件程序中使用。 禁止在组织外部或代理/客户关系中共享许可证,因为它们是不可转让的。 此许可证类型与所有其他许可证类型一样,明确排除未经协议明确授予的所有权利,未经 OEM 重新分发,不购买额外保障即将 Iron Software 用作 SaaS。 定价:每年起价$799。 专业许可证 10名开发者 10个地点 10个项目 永久许可证 此许可证允许组织内的一定数量软件开发人员在多个地点(最多达到十个)使用 Iron Software。 可以在任意多的网站、内联网应用程序或桌面软件应用程序中使用 Iron Managed 公司。许可证不可转让,也不能在组织或代理/客户关系之外共享。该许可证类型与所有其他许可证类型一样,明确排除协议中未明确授予的所有权利,包括 OEM 再分配和在未经许可的情况下在 SaaS 中使用它未购买额外覆盖的 Iron 软件的权利。 此许可证可以与单个项目中的最多十个项目集成。 定价:每年起价为$999。 无限许可证 无限开发人员 无限地点 无限项目 永久许可证 此许可证允许组织中的无限数量的软件开发人员在无限数量的位置使用 Iron 软件。 Iron Software 可以在任意数量的内部网络应用程序、桌面软件应用程序或网站中使用。许可证是不可转让的,不能在组织外部或代理/客户关系中共享。此许可证类型与所有其他许可证类型一样,明确排除所有未在协议下授予的权利,包括 OEM 重新分发和将 Iron Software 用作 SaaS,未经购买额外保障。 定价:每年起价$4,799。 免版税再分发 - 这允许您根据基许可证所涵盖的项目数量,将 Iron 软件作为多个不同打包的商业产品的一部分(无需支付版税)进行分发。 这将允许 Iron Software 在 SaaS 软件服务中部署,基于基础许可证涵盖的项目数量。 定价:每年起价为$1,599。 PDFTron 许可证模式和定价 PDFTron 套餐(定制许可证) 定制许可证的价格各异 - 获得报价以符合您的特定预算。 部署 PDFTron 强大的文档查看和编辑技术,用于在 Web、移动和桌面平台上的渲染和文档处理 准备集成,OEM 再分发,以及大量文档量或具有独特需求的组织 多域定价和优惠的多年折扣 支持离线和沙盒操作 定制、全面的合同条款 咨询和培训服务 PDFTron 定制许可证旨在符合您的应用程序和业务需求。 定价取决于您的功能范围。 IronOCR Lite 许可证是一个未定义的套餐,包含一个开发人员和一年的支持,费用约为 $799。 IronOCR 专业许可证包括 10 名开发人员套餐和一年的支持费用为 $999,而 PDFTron 套餐则未定义。 要购买套餐,您必须联系支持中心获取报价。 IronOCR Lite 和 Professional 套餐包括 OEM 或 SaaS 服务,并提供 5 年支持选项。 Lite 版本包括一个开发者包,具有 5 年支持和 SaaS 和 OEM 服务费用 2,897 美元,并提供定制支持选项。 IronOCR Professional 版本包含 10 名开发人员套餐,具 5 年支持,Saas 和 OEM 服务费用 3,397 美元。而 PDFTron 的 10 名开发者套餐具有一年的支持、SaaS 和 OEM 服务,却没有定义的价格。 7.0 结论 在 .NET Framework 上下文中的 IronOCR 提供易于使用的 Tesseract 并支持通过多种方式实现的照片和 PDF 文档。 它还提供多种选项以提高 Tesseract OCR 的性能。 支持多种语言,并且能够在单个操作中使用多种语言。 访问他们的网站了解更多关于 Tesseract OCR 的信息。 PDFTron 是一个使用不同引擎识别图像和 PDF 文档的软件应用程序。 它还提供各种设置以提高 OCR 过程的性能,并可选择多种语言。 PDFTron 在页面转换的使用上存在限制。 它还具有针对不同操作系统的各种价格。 IronOCR 是一个具有竞争力的软件产品,能够提供比竞争品牌更高的准确性。 类似产品在识别低质量图像时有时会失败,导致未知字符。 另一方面,IronOCR 不仅提供准确的结果,还允许我们识别条形码数据并读取图像中的条形码值。 IronOCR 套餐为所有平台提供具有竞争力的许可和支持,并且定价一致。 相比之下,PDFTron 的 OCR 产品都是独家定制选择,往往更昂贵。两个产品之间的定价不同,IronOCR 的起价为 $799,而由于定制选择,PDFTron 的起价未定义。 综上所述,IronOCR 在较低的价格提供更多的功能种类。 那么,您在等什么? 免费试用对所有人开放。 在 此处获取许可证并立即开始使用! 请注意PDFTron OCR 是其各自所有者的注册商标。 本网站与 PDFTron OCR 无关、未获其认可或赞助。 所有产品名称、徽标和品牌均为各自所有者的财产。 比较仅供参考,反映的是撰写时的公开信息。 常见问题解答 什么是光学字符识别(OCR)及其重要性? 光学字符识别(OCR)是一种用于将纸质文件或图像转换为可读文本的技术。它对于在法律、商业和学术领域中的应用至关重要,能够将扫描文件和PDF转换为其原始文本格式。 如何将OCR功能集成到C#应用程序中? 您可以使用IronOCR将OCR功能集成到C#应用程序中,它可与.NET应用程序无缝集成,并支持多种语言和条码格式。 IronOCR的安装步骤是什么? IronOCR可以通过Visual Studio使用NuGet包管理器进行安装。您还可以使用Visual Studio命令行,直接从NuGet网站下载,或从IronOCR网站获取。 PDFTron OCR与IronOCR之间的关键区别是什么? PDFTron OCR需要一个单独的附加模块,并提供多样化的文档格式,而IronOCR则提供卓越的.NET集成,支持更多语言,并以易用性为重点提供具有竞争力的定价。 IronOCR如何处理低质量扫描? IronOCR设计用于纠正低质量扫描,即使原始图像质量不高,仍然提供准确的文本识别和结构化数据输出。 IronOCR的语言支持能力如何? IronOCR支持125种语言,使其成为需要OCR功能的全球应用程序的多功能选项。 IronOCR可以用于条码识别吗? 是的,IronOCR不仅支持文本读取,还支持从PDF和图像中读取QR码和条码,提高了其在各种应用中的实用性。 OCR技术的一些常见用例是什么? OCR技术常用于转换扫描的法律文件、自动化数据输入、使PDF可搜索,以及通过将文本转换为音频来帮助视力受损用户。 IronOCR与PDFTron OCR相比如何定价? IronOCR提供简单的永久许可证,适合不同用户需求,而PDFTron OCR的定价是根据特定应用需求定制的,通常导致较高的成本。 使用IronOCR将图像转换为文本的过程是什么? 使用IronOCR,您可以利用其OCR功能在.NET应用程序中将图像转换为文本,充分利用其对多种图像格式和语言的支持。 Kannapat Udonpant 立即与工程团队聊天 软件工程师 在成为软件工程师之前,Kannapat 在日本北海道大学完成了环境资源博士学位。在攻读学位期间,Kannapat 还成为了车辆机器人实验室的成员,隶属于生物生产工程系。2022 年,他利用自己的 C# 技能加入 Iron Software 的工程团队,专注于 IronPDF。Kannapat 珍视他的工作,因为他可以直接从编写大多数 IronPDF 代码的开发者那里学习。除了同行学习外,Kannapat 还喜欢在 Iron Software 工作的社交方面。不撰写代码或文档时,Kannapat 通常可以在他的 PS5 上玩游戏或重温《最后生还者》。 相关文章 已发布十二月 18, 2025 适用于 Windows 10 的最佳 OCR 软件:完整对比指南 [2025] 了解适用于 Windows 10 的最佳 OCR 软件。 阅读更多 已发布十二月 11, 2025 Tesseract OCR PDF to Text C#:开发人员与 IronOCR 的比较 了解如何使用 Tesseract OCR 和 IronOCR 轻松地将 PDF 转换为文本。 阅读更多 已发布十二月 11, 2025 使用 Tesseract C# 与 IronOCR:.NET 中实现 OCR 的完整指南 了解如何高效使用 Tesseract C# 和 IronOCR 进行光学字符识别。 阅读更多 Tesseract 的替代方案(2022 更新)IronOCR 和 Tesseract.NET 之间的...
已发布十二月 11, 2025 Tesseract OCR PDF to Text C#:开发人员与 IronOCR 的比较 了解如何使用 Tesseract OCR 和 IronOCR 轻松地将 PDF 转换为文本。 阅读更多
已发布十二月 11, 2025 使用 Tesseract C# 与 IronOCR:.NET 中实现 OCR 的完整指南 了解如何高效使用 Tesseract C# 和 IronOCR 进行光学字符识别。 阅读更多