跳至頁尾內容

VB.NET 入門程式碼

C# + VB.NET: AutoOcr AutoOcr
using IronOcr;

string imageText = new IronTesseract().Read(@"images\image.png").Text;
Imports IronOcr

Private imageText As String = (New IronTesseract()).Read("images\image.png").Text
Install-Package IronOcr

IronOCR 具備獨特能力,能自動偵測並讀取來自掃描品質不佳的圖像及 PDF 文件中的文字。 IronTesseract 類別提供了最簡單的 API。

嘗試其他程式碼範例,以精細控制您的 C# OCR 操作。

IronOCR 提供目前已知最先進的 Tesseract 版本,適用於任何平台,具備更快的速度、更高的精準度,並包含原生 DLL 及 API。

支援 Tesseract 3、Tesseract 4 及 Tesseract 5 版本,適用於 .NET Framework、.NET Standard、Core、Xamarin 及 Mono。

Explore the IronTesseract C# OCR How-To Guide

C# + VB.NET: 國際語言 國際語言
using IronOcr;
using System;

var ocrTesseract = new IronTesseract();

ocrTesseract.Language = OcrLanguage.Arabic;

using (var ocrInput = new OcrInput())
{
    ocrInput.LoadImage(@"images\arabic.gif");
    var ocrResult = ocrTesseract.Read(ocrInput);
    Console.WriteLine(ocrResult.Text);
}

// Example with a Custom Trained Font Being used:

var ocrTesseractCustomerLang = new IronTesseract();
ocrTesseractCustomerLang.UseCustomTesseractLanguageFile("custom_tesseract_files/custom.traineddata");
ocrTesseractCustomerLang.AddSecondaryLanguage(OcrLanguage.EnglishBest);

using (var ocrInput = new OcrInput())
{
    ocrInput.LoadPdf(@"images\mixed-lang.pdf");
    var ocrResult = ocrTesseractCustomerLang.Read(ocrInput);
    Console.WriteLine(ocrResult.Text);
}
Imports IronOcr
Imports System

Private ocrTesseract = New IronTesseract()

ocrTesseract.Language = OcrLanguage.Arabic

Using ocrInput As New OcrInput()
	ocrInput.LoadImage("images\arabic.gif")
	Dim ocrResult = ocrTesseract.Read(ocrInput)
	Console.WriteLine(ocrResult.Text)
End Using

' Example with a Custom Trained Font Being used:

Dim ocrTesseractCustomerLang = New IronTesseract()
ocrTesseractCustomerLang.UseCustomTesseractLanguageFile("custom_tesseract_files/custom.traineddata")
ocrTesseractCustomerLang.AddSecondaryLanguage(OcrLanguage.EnglishBest)

Using ocrInput As New OcrInput()
	ocrInput.LoadPdf("images\mixed-lang.pdf")
	Dim ocrResult = ocrTesseractCustomerLang.Read(ocrInput)
	Console.WriteLine(ocrResult.Text)
End Using
Install-Package IronOcr

IronOCR 語言支援

IronOCR 支援 125 種國際語言。 除了預設安裝的英文外,您可透過 NuGet 將其他語言套件新增至您的 .NET 專案,或從我們的語言頁面下載。

多數語言皆提供 Standard(建議)及 Best 品質等級。 Best 品質選項雖能提供更精準的結果,但處理時間也會較長。

透過 IronOCR 探索多語言 OCR 功能。

C# + VB.NET: 結果物件 結果物件
using IronOcr;
using IronSoftware.Drawing;

// We can delve deep into OCR results as an object model of
// Pages, Barcodes, Paragraphs, Lines, Words and Characters
// This allows us to explore, export and draw OCR content using other APIs/
var ocrTesseract = new IronTesseract();

ocrTesseract.Configuration.ReadBarCodes = true;

using var ocrInput = new OcrInput();
var pages = new int[] { 1, 2 };
ocrInput.LoadImageFrames("example.tiff", pages);

OcrResult ocrResult = ocrTesseract.Read(ocrInput);
foreach (var page in ocrResult.Pages)
{
    // Page object
    int PageNumber = page.PageNumber;
    string PageText = page.Text;
    int PageWordCount = page.WordCount;
    // null if we dont set Ocr.Configuration.ReadBarCodes = true;
    OcrResult.Barcode[] Barcodes = page.Barcodes;
    AnyBitmap PageImage = page.ToBitmap(ocrInput);
    double PageWidth = page.Width;
    double PageHeight = page.Height;
    double PageRotation = page.Rotation; // angular correction in degrees from OcrInput.Deskew()

    foreach (var paragraph in page.Paragraphs)
    {
        // Pages -> Paragraphs
        int ParagraphNumber = paragraph.ParagraphNumber;
        string ParagraphText = paragraph.Text;
        AnyBitmap ParagraphImage = paragraph.ToBitmap(ocrInput);
        int ParagraphX_location = paragraph.X;
        int ParagraphY_location = paragraph.Y;
        int ParagraphWidth = paragraph.Width;
        int ParagraphHeight = paragraph.Height;
        double ParagraphOcrAccuracy = paragraph.Confidence;
        OcrResult.TextFlow paragrapthText_direction = paragraph.TextDirection;
        foreach (var line in paragraph.Lines)
        {
            // Pages -> Paragraphs -> Lines
            int LineNumber = line.LineNumber;
            string LineText = line.Text;
            AnyBitmap LineImage = line.ToBitmap(ocrInput);
            int LineX_location = line.X;
            int LineY_location = line.Y;
            int LineWidth = line.Width;
            int LineHeight = line.Height;
            double LineOcrAccuracy = line.Confidence;
            double LineSkew = line.BaselineAngle;
            double LineOffset = line.BaselineOffset;
            foreach (var word in line.Words)
            {
                // Pages -> Paragraphs -> Lines -> Words
                int WordNumber = word.WordNumber;
                string WordText = word.Text;
                AnyBitmap WordImage = word.ToBitmap(ocrInput);
                int WordX_location = word.X;
                int WordY_location = word.Y;
                int WordWidth = word.Width;
                int WordHeight = word.Height;
                double WordOcrAccuracy = word.Confidence;
                foreach (var character in word.Characters)
                {
                    // Pages -> Paragraphs -> Lines -> Words -> Characters
                    int CharacterNumber = character.CharacterNumber;
                    string CharacterText = character.Text;
                    AnyBitmap CharacterImage = character.ToBitmap(ocrInput);
                    int CharacterX_location = character.X;
                    int CharacterY_location = character.Y;
                    int CharacterWidth = character.Width;
                    int CharacterHeight = character.Height;
                    double CharacterOcrAccuracy = character.Confidence;
                    // Output alternative symbols choices and their probability.
                    // Very useful for spellchecking
                    OcrResult.Choice[] Choices = character.Choices;
                }
            }
        }
    }
}
Imports IronOcr
Imports IronSoftware.Drawing

' We can delve deep into OCR results as an object model of
' Pages, Barcodes, Paragraphs, Lines, Words and Characters
' This allows us to explore, export and draw OCR content using other APIs/
Private ocrTesseract = New IronTesseract()

ocrTesseract.Configuration.ReadBarCodes = True

Dim ocrInput As New OcrInput()
Dim pages = New Integer() { 1, 2 }
ocrInput.LoadImageFrames("example.tiff", pages)

Dim ocrResult As OcrResult = ocrTesseract.Read(ocrInput)
For Each page In ocrResult.Pages
	' Page object
	Dim PageNumber As Integer = page.PageNumber
	Dim PageText As String = page.Text
	Dim PageWordCount As Integer = page.WordCount
	' null if we dont set Ocr.Configuration.ReadBarCodes = true;
	Dim Barcodes() As OcrResult.Barcode = page.Barcodes
	Dim PageImage As AnyBitmap = page.ToBitmap(ocrInput)
	Dim PageWidth As Double = page.Width
	Dim PageHeight As Double = page.Height
	Dim PageRotation As Double = page.Rotation ' angular correction in degrees from OcrInput.Deskew()

	For Each paragraph In page.Paragraphs
		' Pages -> Paragraphs
		Dim ParagraphNumber As Integer = paragraph.ParagraphNumber
		Dim ParagraphText As String = paragraph.Text
		Dim ParagraphImage As AnyBitmap = paragraph.ToBitmap(ocrInput)
		Dim ParagraphX_location As Integer = paragraph.X
		Dim ParagraphY_location As Integer = paragraph.Y
		Dim ParagraphWidth As Integer = paragraph.Width
		Dim ParagraphHeight As Integer = paragraph.Height
		Dim ParagraphOcrAccuracy As Double = paragraph.Confidence
		Dim paragrapthText_direction As OcrResult.TextFlow = paragraph.TextDirection
		For Each line In paragraph.Lines
			' Pages -> Paragraphs -> Lines
			Dim LineNumber As Integer = line.LineNumber
			Dim LineText As String = line.Text
			Dim LineImage As AnyBitmap = line.ToBitmap(ocrInput)
			Dim LineX_location As Integer = line.X
			Dim LineY_location As Integer = line.Y
			Dim LineWidth As Integer = line.Width
			Dim LineHeight As Integer = line.Height
			Dim LineOcrAccuracy As Double = line.Confidence
			Dim LineSkew As Double = line.BaselineAngle
			Dim LineOffset As Double = line.BaselineOffset
			For Each word In line.Words
				' Pages -> Paragraphs -> Lines -> Words
				Dim WordNumber As Integer = word.WordNumber
				Dim WordText As String = word.Text
				Dim WordImage As AnyBitmap = word.ToBitmap(ocrInput)
				Dim WordX_location As Integer = word.X
				Dim WordY_location As Integer = word.Y
				Dim WordWidth As Integer = word.Width
				Dim WordHeight As Integer = word.Height
				Dim WordOcrAccuracy As Double = word.Confidence
				For Each character In word.Characters
					' Pages -> Paragraphs -> Lines -> Words -> Characters
					Dim CharacterNumber As Integer = character.CharacterNumber
					Dim CharacterText As String = character.Text
					Dim CharacterImage As AnyBitmap = character.ToBitmap(ocrInput)
					Dim CharacterX_location As Integer = character.X
					Dim CharacterY_location As Integer = character.Y
					Dim CharacterWidth As Integer = character.Width
					Dim CharacterHeight As Integer = character.Height
					Dim CharacterOcrAccuracy As Double = character.Confidence
					' Output alternative symbols choices and their probability.
					' Very useful for spellchecking
					Dim Choices() As OcrResult.Choice = character.Choices
				Next character
			Next word
		Next line
	Next paragraph
Next page
Install-Package IronOcr

IronOCR 會針對其掃描的每一頁,使用 Tesseract 5\ 返回一個進階結果物件。 此內容包含位置資料、圖片、文字、統計置信度、替代符號選項、字型名稱、字型大小、裝飾效果、字型粗細,以及各項的相對位置

  • Page
  • Paragraph
  • 文字行
  • Word
  • 個別字元
  • Barcode

探索如何使用 IronOCR 讀取 OCR 結果

Human Support related to VB.NET 中的 OCR

來自我們團隊的支援

若對產品或授權有任何疑問,Iron 團隊隨時準備為您提供支援。請將您的問題發送給我們,我們將確保由 Iron 的相關人員為您解答。

聯絡我們
Image To Text related to VB.NET 中的 OCR

在 VB.NET 應用程式中將 OCR 圖像轉為文字

可將單一或多頁文件傳送至 IronOCR。您將收到包含所有文字、BarCode 及 QR 碼內容的結果。為 .NET 控制台、網頁或桌面應用程式新增 OCR 功能。支援提交的圖像格式包括 PDF、JPG、PNG、GIF、BMP 及 TIFF。

專為 VB.NET, .NET, C#

查看教學指南
Fast And Polite Behavior related to VB.NET 中的 OCR

快速且精準的 OCR 結果

光學字元辨識 (OCR) 軟體會分析多種字型樣式的內容,以實現精準的文字辨識。使用矩形讀取區域可提升速度與準確度。多核心多執行緒技術可提升 OCR 讀取速度。

API 參考文件
Advanced Image related to VB.NET 中的 OCR

針對不完美掃描的圖像處理

IronOCR 真正獨特之處在於其能讀取掃描品質不佳的文件。其獨特的預處理函式庫可降低背景雜訊、修正旋轉、變形與對齊偏差,同時簡化色彩並提升解析度與對比度。Iron 的「自動 OCR」與「進階 OCR」設定,為開發者提供工具,確保每次都能獲得最佳結果。

了解更多
Support For Languages related to VB.NET 中的 OCR

多語言 OCR

提供以下語言套件:阿拉伯語、簡體中文、繁體中文、丹麥語、英語、芬蘭語、法語、德語、希伯來語、義大利語、日語、韓語、葡萄牙語、俄語、西班牙語及瑞典語。其他語言可依需求提供支援。

了解更多
Output Content related to VB.NET 中的 OCR

資料直接匯出至您的 VB.NET 應用程式

IronOCR 會將內容輸出為純文字及 BarCode 資料。 另一種結構化資料物件模型則允許開發人員以結構化的標題、段落、行、單字及字元格式接收所有內容,以便直接輸入至 .NET 應用程式中。

了解更多
支援:
  • .NET Framework 4.0 及以上版本支援 C#、VB、F#
  • Microsoft Visual Studio .NET 開發整合開發環境 (IDE) 圖示
  • Visual Studio 的 NuGet 安裝程式支援
  • 相容於 JetBrains ReSharper C# 語言輔助工具
  • 相容於 Microsoft Azure C# .NET 託管平台

授權與定價

免費的社群開發授權。商業授權價格自 749 美元起。

專案 C# + VB.NET 函式庫授權

專案

開發者 C# + VB.NET 函式庫授權

開發者

組織 C# + VB.NET 函式庫授權

組織架構

Agency C# + VB.NET 函式庫授權

代理商

SaaS C# + VB.NET 函式庫授權

SaaS

OEM C# + VB.NET 函式庫授權

OEM

查看完整授權選項  

VB.NET 光學字元辨識教學

C# 版 Tesseract 教學 | IronOCR

C# Tesseract OCR

Jim Baker 是 Iron 公司負責 OCR 產品開發的開發工程師

IronOCR 與 Tesseract 在 .NET 平台上的比較

Jim 是 IronOCR 開發領域的領軍人物。Jim 負責設計並建構用於 OCR 的影像處理演算法與讀取方法。

參閱 Jim 的 Tesseract 比較分析
如何在 .NET 中從圖片讀取文字 | 教學指南

C# OCR ASP.NET

Gemma Beckford - Microsoft 解決方案工程師

如何在 C# .NET 中從圖片讀取文字

瞭解 Gemma 的團隊如何運用 IronOCR 從圖像中讀取文字,以供其歸檔軟體使用。Gemma 分享了她自己的程式碼範例。

查看 Gemma 的「圖片轉文字」教學
VB 程式設計師使用 IronOcr 來...

會計與財務系統

  • # 收據
  • # 報告
  • # 發票列印
為 ASP.NET 會計與財務系統新增 PDF 支援

企業數位化

  • # 文件說明
  • # 排序與標籤
  • # 紙本替代方案
C# 企業數位化應用案例

Enterprise內容管理

  • # 內容製作
  • # 文件管理
  • # 內容發佈
.NET CMS PDF 支援

資料與報表應用程式

  • # 效能追蹤
  • # 趨勢圖譜
  • # 報告
C# PDF 報表
Iron .NET 客戶

數以千計的企業、政府機構、中小企業及開發者皆信賴 Iron Software產品。

Team Iron 在 .NET 軟體元件市場擁有超過 10 年的經驗。

Nexudus
GE
Vireq
Medcode
Foley
Equinor
ANZ
Marval

鋼鐵支援團隊

我們每週 5 天,每天 24 小時在線上。
聊天
電子郵件
打電話給我