使用 IRONOCR 發票 OCR API 開發者教學 Kannapat Udonpant 更新日期:6月 22, 2025 Download IronOCR NuGet 下載 DLL 下載 Windows 安裝程式 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article 發票OCR API利用機器學習和計算機視覺將發票數據轉換為適合自動處理的格式。 這項技術解決了手動數據輸入的問題,如延遲、成本和錯誤,準確提取供應商信息、發票號和價格等詳細信息,無論是數字還是掃描的發票。 本文將使用名為IronOCR的頂級發票OCR API。 class="hsg-featured-snippet"> 如何創建發票OCR API 下載並安裝發票OCR API 在Visual Studio中創建一個新的C#項目或打開一個已存在的項目。 使用OcrInput方法加載一個現有的圖像文件 使用Ocr.Read方法從圖像中提取文本。 使用Console.WriteLine在控制台中打印提取的文本 1. IronOCR IronOCR,由Iron Software開發,是一個為開發者提供多種工具的OCR庫。 它使用機器學習和計算機視覺從掃描文檔、圖像和PDF中提取文本,實現自動化處理。 它的API可以集成到各種語言和平臺中,減少手動輸入錯誤,提高效率。 提取的數據可以被分析並集成到現有系統中,幫助決策和提高生產力。 Features like image preprocessing, barcode recognition, and file parsing increase its versatility. IronOCR使開發者能將文本識別集成到他們的應用程序中。 2. 先決條件 在開始使用IronOCR之前,您需要滿足一些前提條件。 這些先決條件包括: 確保您已經在您的計算機上設置了合適的開發環境。 這通常涉及到安裝例如Visual Studio之類的集成開發環境 (IDE)。 需要具備C#語言的基本知識。 這將使您能夠有效地理解和修改文章中提供的代碼示例。 您需要在您的項目中安裝IronOCR庫。 這可以通過Visual Studio中的NuGet包管理器或者命令行界面來完成。 通過確保這些前提條件已經滿足,您將準備好開始使用IronOCR。 3. 創建一個新的 Visual Studio 項目 要開始使用IronOCR,第一步是創建一個新的Visual Studio項目。 打開Visual Studio,然後轉到文件,懸停在新建,然後點擊項目。 新项目 在新窗口中,選擇控制台應用程序,然後點擊下一步。 控制台應用 會出現一個新窗口,寫下新項目的名稱和位置,然後點擊下一步。 项目配置 最後,提供目標框架並單擊創建。 目標框架 現在您的新Visual Studio項目已經創建。 讓我們安裝IronOCR。 4. 安裝IronOCR 有幾種方法可以下載並安裝IronOCR庫。 但下面是兩種最簡單的方法。 使用Visual Studio NuGet程序包管理器 使用Visual Studio命令行 4.1. 使用Visual Studio NuGet程序包管理器 使用Visual Studio NuGet包管理器可將IronOCR包含在C#項目中。 通過選擇工具 > NuGet包管理器 > 管理解決方案的NuGet包來導航到NuGet包管理器圖形用戶界面 NuGet 套件管理器 之後,一個新窗口將出現。 搜索 IronOCR 並在項目中安裝該套件。 在NuGet包管理器用戶界面中選擇IronOCR包 也可以使用上述方法安裝 IronOCR 的其他語言包。 4.2. 使用Visual Studio命令行 In Visual Studio, go to Tools > NuGet 套件管理器 > 包管理器控制台 在包管理器控制台標籤中輸入以下行以安裝IronOCR: Install-Package IronOcr 包管理器控制台 現在包將下載/安裝到當前項目並準備使用。 5. 使用IronOCR從發票中提取數據 使用IronOCR,只需幾行代碼即可輕鬆從發票中提取數據,並將提取的數據用於進一步處理,如數據輸入等。 這將取代手動數據輸入等很多操作。 這是一個用於從發票中提取文本的示例。 範例發票 現在,讓我們編寫代碼來提取這份發票的所有數據。 using IronOcr; using System; // Initialize a new instance of the IronTesseract class var ocr = new IronTesseract(); // Use the OcrInput object to load the image file using (var input = new OcrInput(@"r2.png")) { // Read the image using the Read method, which performs OCR var result = ocr.Read(input); // Output the extracted text to the console Console.WriteLine(result.Text); } using IronOcr; using System; // Initialize a new instance of the IronTesseract class var ocr = new IronTesseract(); // Use the OcrInput object to load the image file using (var input = new OcrInput(@"r2.png")) { // Read the image using the Read method, which performs OCR var result = ocr.Read(input); // Output the extracted text to the console Console.WriteLine(result.Text); } Imports IronOcr Imports System ' Initialize a new instance of the IronTesseract class Private ocr = New IronTesseract() ' Use the OcrInput object to load the image file Using input = New OcrInput("r2.png") ' Read the image using the Read method, which performs OCR Dim result = ocr.Read(input) ' Output the extracted text to the console Console.WriteLine(result.Text) End Using $vbLabelText $csharpLabel The above code gets input in the form of an image and then extracts data from that image using a Read method from the IronTesseract class. 發票解析器 5.1. 發票處理以從發票中提取特定數據 您還可以從發票中提取特定的數據,比如客戶發票號碼。 下面是從發票中提取客戶發票號碼的代碼。 using IronOcr; using System; using System.Text.RegularExpressions; // Initialize a new instance of the IronTesseract class var ocr = new IronTesseract(); // Use the OcrInput object to load the image file using (var input = new OcrInput(@"r2.png")) { // Perform OCR on the image var result = ocr.Read(input); // Define a regular expression pattern for the invoice number var linePattern = @"INV\/\d{4}\/\d{5}"; // Match the pattern in the extracted text var lineMatch = Regex.Match(result.Text, linePattern); // Check if the pattern matches any part of the text if (lineMatch.Success) { // If a match is found, print the invoice number var lineValue = lineMatch.Value; Console.WriteLine("Customer Invoice number: " + lineValue); } } using IronOcr; using System; using System.Text.RegularExpressions; // Initialize a new instance of the IronTesseract class var ocr = new IronTesseract(); // Use the OcrInput object to load the image file using (var input = new OcrInput(@"r2.png")) { // Perform OCR on the image var result = ocr.Read(input); // Define a regular expression pattern for the invoice number var linePattern = @"INV\/\d{4}\/\d{5}"; // Match the pattern in the extracted text var lineMatch = Regex.Match(result.Text, linePattern); // Check if the pattern matches any part of the text if (lineMatch.Success) { // If a match is found, print the invoice number var lineValue = lineMatch.Value; Console.WriteLine("Customer Invoice number: " + lineValue); } } Imports IronOcr Imports System Imports System.Text.RegularExpressions ' Initialize a new instance of the IronTesseract class Private ocr = New IronTesseract() ' Use the OcrInput object to load the image file Using input = New OcrInput("r2.png") ' Perform OCR on the image Dim result = ocr.Read(input) ' Define a regular expression pattern for the invoice number Dim linePattern = "INV\/\d{4}\/\d{5}" ' Match the pattern in the extracted text Dim lineMatch = Regex.Match(result.Text, linePattern) ' Check if the pattern matches any part of the text If lineMatch.Success Then ' If a match is found, print the invoice number Dim lineValue = lineMatch.Value Console.WriteLine("Customer Invoice number: " & lineValue) End If End Using $vbLabelText $csharpLabel 發票掃描 6. 結論 IronOCR的發票OCR API利用機器學習和計算機視覺革新了從發票中提取數據的方式。 這項技術將發票上的文本和數字轉換為機器可讀格式,簡化數據提取以進行分析、整合和流程改進。 它為自動化發票處理提供了一個強大的解決方案,提高準確性並優化例如應付賬款等工作流程。 利用這項技術,還可以自動從掃描發票中進行數據輸入。 IronOCR提供了高精度,當然是在不進行任何額外設置的情況下使用Tesseract的最佳結果。 It supports multipage frame TIFF, PDF files, and all popular image formats. 它還可以從圖像中讀取條碼值。 欲了解更多有關IronOCR的信息,請訪問主頁網站。 要查看更多關於發票OCR的教程,請訪問此詳細發票OCR教程。 要了解如何使用計算機視覺來識別例如發票字段的文本,請訪問這個計算機視覺操作指南。 常見問題解答 我如何使用 OCR 自動化發票數據處理? 您可以使用 IronOCR 通過其機器學習算法自動化發票數據處理。IronOCR 從數字和掃描的發票中提取如供應商信息、發票號碼和價格等詳細信息,減少手動輸入錯誤並提高效率。 設置發票 OCR API 涉及哪些步驟? 要使用 IronOCR 設置發票 OCR API,首先通過 Visual Studio 的 NuGet Package Manager 下載並安裝庫。接下來,創建一個新的 C# 項目,集成 IronOCR,並使用其方法加載和讀取圖像文件以進行文本提取。 IronOCR 可以提取發票號碼等特定數據嗎? 是的,IronOCR 可以提取如發票號碼等特定數據。它利用正則表達式來匹配提取文本中的模式,允許您從發票中提取特定信息。 IronOCR 有哪些有利於發票處理的功能? IronOCR 包含如圖像預處理、條形碼識別和文件解析等功能。這些功能增強了其從各種發票格式中準確提取和處理文本的能力,提高了數據捕獲和工作流效率。 圖像預處理如何改善 OCR 結果? IronOCR 的圖像預處理通過在文本提取之前優化圖像質量來改善 OCR 結果。這包括如對比度調整和噪聲消除等操作,能夠從發票中更準確地提取數據。 是否可以同時使用 IronOCR 處理數字和掃描的發票? 是的,IronOCR 能夠處理數字和掃描的發票。它利用先進的機器學習和計算機視覺技術從各種格式和圖像質量中準確提取文本。 IronOCR 如何處理多頁格式和文件類型? IronOCR 支持多頁格式和流行的圖像和 PDF 文件類型。它能有效地從複雜文檔中提取文本,使其在各種發票處理應用中非常多才多藝。 開發人員在哪裡可以找到使用 IronOCR 的教程? 開發人員可以在 IronOCR 網站上找到教程和額外資源。該網站提供了一系列學習材料,包括操作指南和博客文章,應用於不同場景中的 IronOCR。 Kannapat Udonpant 立即與工程團隊聊天 軟體工程師 在成為软件工程師之前,Kannapat 從日本北海道大學完成了環境資源博士學位。在追逐學位期间,Kannapat 還成為了生產工程系一部份——汽車机器人实验室的成員。2022 年,他利用他的 C# 技能加入 Iron Software 的工程團隊, 專注於 IronPDF。Kannapat 珍惜他的工作,因为他直接向编写大部分 IronPDF 使用的代码的开发者学习。除了同行学习,Kannapat 还喜欢在 Iron Software 工作的社交十环。当他不编写代码或文档时,Kannapat 通常在他的 PS5 上打游戏或重看《The Last of Us》。 相關文章 發表日期 9月 29, 2025 如何使用 IronOCR 建立 .NET OCR SDK 使用 IronOCR 的 .NET SDK 創建強大的 OCR 解決方案。簡單的 API,企業功能,跨平台支持的文檔處理應用。 閱讀更多 發表日期 9月 29, 2025 如何在 C# GitHub 專案中整合 OCR OCR C# GitHub 教學:使用 IronOCR 在您的 GitHub 專案中實現文本識別。包括程式碼範例和版本控制技巧。 閱讀更多 更新日期 9月 4, 2025 如何將文檔處理記憶體減少 98%:IronOCR 的工程突破 IronOCR 2025.9 通過流式架構將 TIFF 處理記憶體減少 98%,消除崩潰並提高企業工作流程的速度。 閱讀更多 最佳用於發票處理的OCR更新列表如何在 Blazor 中從影像中讀...
發表日期 9月 29, 2025 如何使用 IronOCR 建立 .NET OCR SDK 使用 IronOCR 的 .NET SDK 創建強大的 OCR 解決方案。簡單的 API,企業功能,跨平台支持的文檔處理應用。 閱讀更多
發表日期 9月 29, 2025 如何在 C# GitHub 專案中整合 OCR OCR C# GitHub 教學:使用 IronOCR 在您的 GitHub 專案中實現文本識別。包括程式碼範例和版本控制技巧。 閱讀更多
更新日期 9月 4, 2025 如何將文檔處理記憶體減少 98%:IronOCR 的工程突破 IronOCR 2025.9 通過流式架構將 TIFF 處理記憶體減少 98%,消除崩潰並提高企業工作流程的速度。 閱讀更多