var result = new IronOcr.IronTesseract() { Configuration = new IronOcr.TesseractConfiguration { ReadBarCodes = true } }.Read(new IronOcr.OcrPdfInput("document.pdf"));foreach(var bc in result.Barcodes) Console.WriteLine(bc.Value);
var result = new IronOcr.IronTesseract() { Configuration = new IronOcr.TesseractConfiguration { ReadBarCodes = true } }.Read(new IronOcr.OcrPdfInput("document.pdf"));
foreach(var bc in result.Barcodes) Console.WriteLine(bc.Value);
using IronOcr;using System;// Instantiate IronTesseractIronTesseract ocrTesseract = new IronTesseract();// Enable barcode readingocrTesseract.Configuration.ReadBarCodes = true;// Add PDFusing var imageInput = new OcrPdfInput("pdfWithBarcodes.pdf");// Perform OCROcrResult ocrResult = ocrTesseract.Read(imageInput);// Output detected barcodes and text valuesConsole.WriteLine("Extracted text:");Console.WriteLine(ocrResult.Text);Console.WriteLine("Extracted barcodes:");foreach (var barcode in ocrResult.Barcodes){Console.WriteLine(barcode.Value);}
using IronOcr;
using System;
// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();
// Enable barcode reading
ocrTesseract.Configuration.ReadBarCodes = true;
// Add PDF
using var imageInput = new OcrPdfInput("pdfWithBarcodes.pdf");
// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(imageInput);
// Output detected barcodes and text values
Console.WriteLine("Extracted text:");
Console.WriteLine(ocrResult.Text);
Console.WriteLine("Extracted barcodes:");
foreach (var barcode in ocrResult.Barcodes)
{
Console.WriteLine(barcode.Value);
}
ImportsIronOcrImportsSystem' Instantiate IronTesseractPrivate ocrTesseract As New IronTesseract()' Enable barcode readingocrTesseract.Configuration.ReadBarCodes = True' Add PDFDim imageInput = New OcrPdfInput("pdfWithBarcodes.pdf")' Perform OCRDim ocrResult AsOcrResult = ocrTesseract.Read(imageInput)' Output detected barcodes and text valuesConsole.WriteLine("Extracted text:")Console.WriteLine(ocrResult.Text)Console.WriteLine("Extracted barcodes:")For Each barcode In ocrResult.BarcodesConsole.WriteLine(barcode.Value)Next barcode
Imports IronOcr
Imports System
' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()
' Enable barcode reading
ocrTesseract.Configuration.ReadBarCodes = True
' Add PDF
Dim imageInput = New OcrPdfInput("pdfWithBarcodes.pdf")
' Perform OCR
Dim ocrResult As OcrResult = ocrTesseract.Read(imageInput)
' Output detected barcodes and text values
Console.WriteLine("Extracted text:")
Console.WriteLine(ocrResult.Text)
Console.WriteLine("Extracted barcodes:")
For Each barcode In ocrResult.Barcodes
Console.WriteLine(barcode.Value)
Next barcode
複数の BarCode 値がバーコードの下に表示され、抽出されたテキストに含まれます。
なぜIronOCRはテキストとBarCodeの両方の値を抽出するのですか?
IronOCRの二重抽出は包括的な文書分析を提供します。 テキストとバーコードの両方を含むドキュメントを処理する場合、ライブラリは standard OCR text extraction を実行し、同時にバーコード シンボロジーをデコードします。 この統一されたアプローチにより、複数の処理パスや個別のライブラリが不要になります。
using IronOcr;using System;// Instantiate IronTesseractIronTesseract ocrTesseract = new IronTesseract();// Enable barcode readingocrTesseract.Configuration.ReadBarCodes = true;// Add PDFusing var imageInput = new OcrPdfInput("pdfWithQrCodes.pdf");// Perform OCROcrResult ocrResult = ocrTesseract.Read(imageInput);// Output detected barcodes and text valuesConsole.WriteLine("Extracted text:");Console.WriteLine(ocrResult.Text);Console.WriteLine("Extracted barcodes:");foreach (var barcode in ocrResult.Barcodes){Console.WriteLine(barcode.Value);}
using IronOcr;
using System;
// Instantiate IronTesseract
IronTesseract ocrTesseract = new IronTesseract();
// Enable barcode reading
ocrTesseract.Configuration.ReadBarCodes = true;
// Add PDF
using var imageInput = new OcrPdfInput("pdfWithQrCodes.pdf");
// Perform OCR
OcrResult ocrResult = ocrTesseract.Read(imageInput);
// Output detected barcodes and text values
Console.WriteLine("Extracted text:");
Console.WriteLine(ocrResult.Text);
Console.WriteLine("Extracted barcodes:");
foreach (var barcode in ocrResult.Barcodes)
{
Console.WriteLine(barcode.Value);
}
ImportsIronOcrImportsSystem' Instantiate IronTesseractPrivate ocrTesseract As New IronTesseract()' Enable barcode readingocrTesseract.Configuration.ReadBarCodes = True' Add PDFDim imageInput = New OcrPdfInput("pdfWithQrCodes.pdf")' Perform OCRDim ocrResult AsOcrResult = ocrTesseract.Read(imageInput)' Output detected barcodes and text valuesConsole.WriteLine("Extracted text:")Console.WriteLine(ocrResult.Text)Console.WriteLine("Extracted barcodes:")For Each barcode In ocrResult.BarcodesConsole.WriteLine(barcode.Value)Next barcode
Imports IronOcr
Imports System
' Instantiate IronTesseract
Private ocrTesseract As New IronTesseract()
' Enable barcode reading
ocrTesseract.Configuration.ReadBarCodes = True
' Add PDF
Dim imageInput = New OcrPdfInput("pdfWithQrCodes.pdf")
' Perform OCR
Dim ocrResult As OcrResult = ocrTesseract.Read(imageInput)
' Output detected barcodes and text values
Console.WriteLine("Extracted text:")
Console.WriteLine(ocrResult.Text)
Console.WriteLine("Extracted barcodes:")
For Each barcode In ocrResult.Barcodes
Console.WriteLine(barcode.Value)
Next barcode
// Apply filters to improve QR code readabilityocrTesseract.Configuration.ReadBarCodes = true;var input = new OcrImageInput("qr-code-scan.jpg");input.DeNoise();input.Sharpen();input.EnhanceResolution();var result = ocrTesseract.Read(input);
// Apply filters to improve QR code readability
ocrTesseract.Configuration.ReadBarCodes = true;
var input = new OcrImageInput("qr-code-scan.jpg");
input.DeNoise();
input.Sharpen();
input.EnhanceResolution();
var result = ocrTesseract.Read(input);
' Apply filters to improve QR code readabilityocrTesseract.Configuration.ReadBarCodes = TrueDim input As New OcrImageInput("qr-code-scan.jpg")input.DeNoise()input.Sharpen()input.EnhanceResolution()Dim result = ocrTesseract.Read(input)
' Apply filters to improve QR code readability
ocrTesseract.Configuration.ReadBarCodes = True
Dim input As New OcrImageInput("qr-code-scan.jpg")
input.DeNoise()
input.Sharpen()
input.EnhanceResolution()
Dim result = ocrTesseract.Read(input)
// Enhanced QR code reading with preprocessingvar ocrTesseract = new IronTesseract();ocrTesseract.Configuration.ReadBarCodes = true;// Configure for better QR detectionvar input = new OcrImageInput("document-with-qr.pdf");input.TargetDPI = 300; // Ensure sufficient resolutioninput.Binarize(); // Convert to black and whiteinput.DeNoise(); // Remove image artifactsvar result = ocrTesseract.Read(input);
// Enhanced QR code reading with preprocessing
var ocrTesseract = new IronTesseract();
ocrTesseract.Configuration.ReadBarCodes = true;
// Configure for better QR detection
var input = new OcrImageInput("document-with-qr.pdf");
input.TargetDPI = 300; // Ensure sufficient resolution
input.Binarize(); // Convert to black and white
input.DeNoise(); // Remove image artifacts
var result = ocrTesseract.Read(input);
ImportsIronTesseract' Enhanced QR code reading with preprocessingDim ocrTesseract = New IronTesseract()ocrTesseract.Configuration.ReadBarCodes = True' Configure for better QR detectionDim input = New OcrImageInput("document-with-qr.pdf")input.TargetDPI = 300 ' Ensure sufficient resolutioninput.Binarize() ' Convert to black and whiteinput.DeNoise() ' Remove image artifactsDim result = ocrTesseract.Read(input)
Imports IronTesseract
' Enhanced QR code reading with preprocessing
Dim ocrTesseract = New IronTesseract()
ocrTesseract.Configuration.ReadBarCodes = True
' Configure for better QR detection
Dim input = New OcrImageInput("document-with-qr.pdf")
input.TargetDPI = 300 ' Ensure sufficient resolution
input.Binarize() ' Convert to black and white
input.DeNoise() ' Remove image artifacts
Dim result = ocrTesseract.Read(input)
// Process multi-page documents efficientlyusing var pdfInput = new OcrPdfInput("multi-page-qr-document.pdf");pdfInput.TargetDPI = 300;var results = ocrTesseract.Read(pdfInput);foreach (var page in results.Pages){Console.WriteLine($"Page {page.PageNumber}:"); foreach (var barcode in page.Barcodes) {Console.WriteLine($" QR Code: {barcode.Value}");Console.WriteLine($" Location: X={barcode.X}, Y={barcode.Y}"); }}
// Process multi-page documents efficiently
using var pdfInput = new OcrPdfInput("multi-page-qr-document.pdf");
pdfInput.TargetDPI = 300;
var results = ocrTesseract.Read(pdfInput);
foreach (var page in results.Pages)
{
Console.WriteLine($"Page {page.PageNumber}:");
foreach (var barcode in page.Barcodes)
{
Console.WriteLine($" QR Code: {barcode.Value}");
Console.WriteLine($" Location: X={barcode.X}, Y={barcode.Y}");
}
}
ImportsSystem' Process multi-page documents efficientlyUsing pdfInput As New OcrPdfInput("multi-page-qr-document.pdf") pdfInput.TargetDPI = 300 Dim results = ocrTesseract.Read(pdfInput) For Each page In results.PagesConsole.WriteLine($"Page {page.PageNumber}:") For Each barcode In page.BarcodesConsole.WriteLine($" QR Code: {barcode.Value}")Console.WriteLine($" Location: X={barcode.X}, Y={barcode.Y}") Next NextEndUsing
Imports System
' Process multi-page documents efficiently
Using pdfInput As New OcrPdfInput("multi-page-qr-document.pdf")
pdfInput.TargetDPI = 300
Dim results = ocrTesseract.Read(pdfInput)
For Each page In results.Pages
Console.WriteLine($"Page {page.PageNumber}:")
For Each barcode In page.Barcodes
Console.WriteLine($" QR Code: {barcode.Value}")
Console.WriteLine($" Location: X={barcode.X}, Y={barcode.Y}")
Next
Next
End Using
// Process multiple documents in parallelvar documents = new[] { "doc1.pdf", "doc2.pdf", "doc3.pdf" };var results = documents.AsParallel().Select(doc =>{ var tesseract = new IronTesseract(); tesseract.Configuration.ReadBarCodes = true; return tesseract.Read(new OcrPdfInput(doc));}).ToList();
// Process multiple documents in parallel
var documents = new[] { "doc1.pdf", "doc2.pdf", "doc3.pdf" };
var results = documents.AsParallel().Select(doc =>
{
var tesseract = new IronTesseract();
tesseract.Configuration.ReadBarCodes = true;
return tesseract.Read(new OcrPdfInput(doc));
}).ToList();
ImportsIronTesseract' Process multiple documents in parallelDim documents = {"doc1.pdf", "doc2.pdf", "doc3.pdf"}Dim results = documents.AsParallel().Select(Function(doc) Dim tesseract = New IronTesseract() tesseract.Configuration.ReadBarCodes = True Return tesseract.Read(New OcrPdfInput(doc))End Function).ToList()
Imports IronTesseract
' Process multiple documents in parallel
Dim documents = {"doc1.pdf", "doc2.pdf", "doc3.pdf"}
Dim results = documents.AsParallel().Select(Function(doc)
Dim tesseract = New IronTesseract()
tesseract.Configuration.ReadBarCodes = True
Return tesseract.Read(New OcrPdfInput(doc))
End Function).ToList()
// Implement cancellation for large batch processingusing var cts = new CancellationTokenSource();ocrTesseract.Configuration.CancellationToken = cts.Token;// Cancel if processing takes too longcts.CancelAfter(TimeSpan.FromMinutes(5));
// Implement cancellation for large batch processing
using var cts = new CancellationTokenSource();
ocrTesseract.Configuration.CancellationToken = cts.Token;
// Cancel if processing takes too long
cts.CancelAfter(TimeSpan.FromMinutes(5));
' Implement cancellation for large batch processingUsing cts As New CancellationTokenSource() ocrTesseract.Configuration.CancellationToken = cts.Token ' Cancel if processing takes too long cts.CancelAfter(TimeSpan.FromMinutes(5))EndUsing
' Implement cancellation for large batch processing
Using cts As New CancellationTokenSource()
ocrTesseract.Configuration.CancellationToken = cts.Token
' Cancel if processing takes too long
cts.CancelAfter(TimeSpan.FromMinutes(5))
End Using
How can I improve the accuracy of QR code recognition with IronOCR?
Improve QR code recognition by ensuring high resolution, applying image corrections like de-noising and sharpening, and handling orientation issues.
What are common challenges when reading QR codes with OCR?
Common challenges include resolution issues, image quality problems, orientation errors, and interference from overlapping text or graphics.
Can IronOCR handle multi-page PDF documents with barcodes?
Yes, IronOCR can process multi-page PDF documents with barcodes by reading each page individually and outputting detected barcode values and formats.
What is the benefit of using IronOCR for PDF text extraction and barcode reading?
Using IronOCR allows for unified text and barcode extraction from PDF documents, reducing the need for separate libraries and processing steps for each type of data.
How can IronOCR's barcode capabilities integrate into business applications?
IronOCR can be used in various business applications such as inventory management, document archiving, invoice processing, and healthcare records by extracting and processing barcode information.