此程式碼範例演示如何使用IronTesseract OCR引擎從PDF文件中提取文字和表格資料。
- 建立
IronTesseractOCR引擎的實例。 - 初始化
table.pdf)。 - OCR引擎使用
OcrResult物件。 - 使用
CellInfos提取該表的單元格資訊。 - 現在,單元格資料列表(
cellList)包含了表格的單元格,包括文字內容和其他細節(例如:單元格位置、大小)。 - 此方法對於從PDF中提取表格等結構化資料非常有用,允許程式化存取和處理每個表格單元格內的文字。
using IronOcr;
using System.Linq;
// Instantiate OCR engine
var ocr = new IronTesseract();
using var input = new OcrInput();
input.LoadPdf("table.pdf");
// Perform OCR
var result = ocr.ReadDocumentAdvanced(input);
var cellList = result.Tables.First().CellInfos;
Imports IronOcr
Imports System.Linq
' Instantiate OCR engine
Dim ocr = New IronTesseract()
Using input = New OcrInput()
input.LoadPdf("table.pdf")
' Perform OCR
Dim result = ocr.ReadDocumentAdvanced(input)
Dim cellList = result.Tables.First().CellInfos
End Using此程式碼範例演示如何使用IronTesseract OCR引擎從PDF文件中提取文字和表格資料。
IronTesseract OCR引擎的實例。table.pdf)。OcrResult物件。CellInfos提取該表的單元格資訊。cellList)包含了表格的單元格,包括文字內容和其他細節(例如:單元格位置、大小)。Nuget Downloads 6,236,385|版本:2026.9剛剛發布