using IronBarCode;using IronSoftware.Drawing;using System.Collections.Generic;// Read barcode from PDF fileBarcodeResults result = BarcodeReader.ReadPdf("test.pdf");// Create list for barcodesList<AnyBitmap> barcodeList = new List<AnyBitmap>();foreach (BarcodeResult barcode in result){ barcodeList.Add(barcode.BarcodeImage);}// Create multi-page TIFFAnyBitmap.CreateMultiFrameTiff(barcodeList).SaveAs("barcodeImages.tif");
using IronBarCode;
using IronSoftware.Drawing;
using System.Collections.Generic;
// Read barcode from PDF file
BarcodeResults result = BarcodeReader.ReadPdf("test.pdf");
// Create list for barcodes
List<AnyBitmap> barcodeList = new List<AnyBitmap>();
foreach (BarcodeResult barcode in result)
{
barcodeList.Add(barcode.BarcodeImage);
}
// Create multi-page TIFF
AnyBitmap.CreateMultiFrameTiff(barcodeList).SaveAs("barcodeImages.tif");
ImportsIronBarCodeImportsIronSoftware.DrawingImportsSystem.Collections.Generic' Read barcode from PDF filePrivate result AsBarcodeResults = BarcodeReader.ReadPdf("test.pdf")' Create list for barcodesPrivate barcodeList As New List(OfAnyBitmap)()For Each barcode AsBarcodeResultIn result barcodeList.Add(barcode.BarcodeImage)Next barcode' Create multi-page TIFFAnyBitmap.CreateMultiFrameTiff(barcodeList).SaveAs("barcodeImages.tif")
Imports IronBarCode
Imports IronSoftware.Drawing
Imports System.Collections.Generic
' Read barcode from PDF file
Private result As BarcodeResults = BarcodeReader.ReadPdf("test.pdf")
' Create list for barcodes
Private barcodeList As New List(Of AnyBitmap)()
For Each barcode As BarcodeResult In result
barcodeList.Add(barcode.BarcodeImage)
Next barcode
' Create multi-page TIFF
AnyBitmap.CreateMultiFrameTiff(barcodeList).SaveAs("barcodeImages.tif")
using IronBarCode;using System;// Read barcode from PNGBarcodeResults result = BarcodeReader.Read("bc3.png");// Output barcode type to consoleforeach (BarcodeResult barcode in result){Console.WriteLine("The barcode value is " + barcode.ToString() + " and the barcode type is " + barcode.BarcodeType);}
using IronBarCode;
using System;
// Read barcode from PNG
BarcodeResults result = BarcodeReader.Read("bc3.png");
// Output barcode type to console
foreach (BarcodeResult barcode in result)
{
Console.WriteLine("The barcode value is " + barcode.ToString() + " and the barcode type is " + barcode.BarcodeType);
}
ImportsIronBarCodeImportsSystem' Read barcode from PNGPrivate result AsBarcodeResults = BarcodeReader.Read("bc3.png")' Output barcode type to consoleFor Each barcode AsBarcodeResultIn resultConsole.WriteLine("The barcode value is " & barcode.ToString() & " and the barcode type is " & barcode.BarcodeType)Next barcode
Imports IronBarCode
Imports System
' Read barcode from PNG
Private result As BarcodeResults = BarcodeReader.Read("bc3.png")
' Output barcode type to console
For Each barcode As BarcodeResult In result
Console.WriteLine("The barcode value is " & barcode.ToString() & " and the barcode type is " & barcode.BarcodeType)
Next barcode
Using IronBarcode, users can retrieve the BARCODE value byte array by accessing the BinaryValue property of the BarcodeResult object. これにより、ユーザーはプログラム内でBARCODE value をさらに操作できるようになります。 バイナリ value 出力は、暗号化されたデータやBARCODEでエンコードされたファイル添付を扱う場合、あるいはバイトレベルのデータ処理を必要とするシステムと統合する場合に特に有用です。
以下のコードスニペットは、BARCODE value をバイナリデータとして取得する使用例を示しています:
using IronBarCode;// Read barcode from PNGBarcodeResults result = BarcodeReader.Read("multiple-barcodes.png");int i = 1;foreach (BarcodeResult barcode in result){ var binaryValue = barcode.BinaryValue; var barcodeType = IronBarCode.BarcodeEncoding.QRCode; // Create QR code GeneratedBarcode generatedBarcode = BarcodeWriter.CreateBarcode(binaryValue, barcodeType); // Export QR code generatedBarcode.SaveAsPng($"qrFromBinary{i}.png"); i++;}
using IronBarCode;
// Read barcode from PNG
BarcodeResults result = BarcodeReader.Read("multiple-barcodes.png");
int i = 1;
foreach (BarcodeResult barcode in result)
{
var binaryValue = barcode.BinaryValue;
var barcodeType = IronBarCode.BarcodeEncoding.QRCode;
// Create QR code
GeneratedBarcode generatedBarcode = BarcodeWriter.CreateBarcode(binaryValue, barcodeType);
// Export QR code
generatedBarcode.SaveAsPng($"qrFromBinary{i}.png");
i++;
}
ImportsIronBarCode' Read barcode from PNGPrivate result AsBarcodeResults = BarcodeReader.Read("multiple-barcodes.png")Private i AsInteger = 1For Each barcode AsBarcodeResultIn result Dim binaryValue = barcode.BinaryValue Dim barcodeType = IronBarCode.BarcodeEncoding.QRCode ' Create QR code Dim generatedBarcode AsGeneratedBarcode = BarcodeWriter.CreateBarcode(binaryValue, barcodeType) ' Export QR code generatedBarcode.SaveAsPng($"qrFromBinary{i}.png") i += 1Next barcode
Imports IronBarCode
' Read barcode from PNG
Private result As BarcodeResults = BarcodeReader.Read("multiple-barcodes.png")
Private i As Integer = 1
For Each barcode As BarcodeResult In result
Dim binaryValue = barcode.BinaryValue
Dim barcodeType = IronBarCode.BarcodeEncoding.QRCode
' Create QR code
Dim generatedBarcode As GeneratedBarcode = BarcodeWriter.CreateBarcode(binaryValue, barcodeType)
' Export QR code
generatedBarcode.SaveAsPng($"qrFromBinary{i}.png")
i += 1
Next barcode
using IronBarCode;using IronSoftware.Drawing;using System.Linq;// Read barcode from PNGBarcodeResults result = BarcodeReader.Read("multiple-barcodes.png");AnyBitmap bitmap = AnyBitmap.FromFile("multiple-barcodes.png");foreach (BarcodeResult barcode in result){ PointF[] barcodePoints = barcode.Points; float x1 = barcodePoints.Select(b => b.X).Min(); float y1 = barcodePoints.Select(b => b.Y).Min(); Rectangle rectangle = new Rectangle((int)x1, (int)y1, (int)barcode.Width!, (int)barcode.Height!); bitmap = bitmap.Redact(rectangle, Color.Magenta); // Save the image bitmap.SaveAs("redacted.png", AnyBitmap.ImageFormat.Png);}
using IronBarCode;
using IronSoftware.Drawing;
using System.Linq;
// Read barcode from PNG
BarcodeResults result = BarcodeReader.Read("multiple-barcodes.png");
AnyBitmap bitmap = AnyBitmap.FromFile("multiple-barcodes.png");
foreach (BarcodeResult barcode in result)
{
PointF[] barcodePoints = barcode.Points;
float x1 = barcodePoints.Select(b => b.X).Min();
float y1 = barcodePoints.Select(b => b.Y).Min();
Rectangle rectangle = new Rectangle((int)x1, (int)y1, (int)barcode.Width!, (int)barcode.Height!);
bitmap = bitmap.Redact(rectangle, Color.Magenta);
// Save the image
bitmap.SaveAs("redacted.png", AnyBitmap.ImageFormat.Png);
}
ImportsSystemImportsIronBarCodeImportsIronSoftware.DrawingImportsSystem.Linq' Read barcode from PNGPrivate result AsBarcodeResults = BarcodeReader.Read("multiple-barcodes.png")Private bitmap AsAnyBitmap = AnyBitmap.FromFile("multiple-barcodes.png")For Each barcode AsBarcodeResultIn result Dim barcodePoints() AsPointF = barcode.Points Dim x1 AsSingle = barcodePoints.Select(Function(b) b.X).Min() Dim y1 AsSingle = barcodePoints.Select(Function(b) b.Y).Min()'INSTANT VB TODO TASK: There is no VB equivalent to the C# 'null-forgiving operator':'ORIGINAL LINE: Rectangle rectangle = new Rectangle((int)x1, (int)y1, (int)barcode.Width!, (int)barcode.Height!); Dim rectangle As New Rectangle(CInt(Math.Truncate(x1)), CInt(Math.Truncate(y1)), CInt(barcode.Width), CInt(barcode.Height)) bitmap = bitmap.Redact(rectangle, Color.Magenta) ' Save the image bitmap.SaveAs("redacted.png", AnyBitmap.ImageFormat.Png)Next barcode
Imports System
Imports IronBarCode
Imports IronSoftware.Drawing
Imports System.Linq
' Read barcode from PNG
Private result As BarcodeResults = BarcodeReader.Read("multiple-barcodes.png")
Private bitmap As AnyBitmap = AnyBitmap.FromFile("multiple-barcodes.png")
For Each barcode As BarcodeResult In result
Dim barcodePoints() As PointF = barcode.Points
Dim x1 As Single = barcodePoints.Select(Function(b) b.X).Min()
Dim y1 As Single = barcodePoints.Select(Function(b) b.Y).Min()
'INSTANT VB TODO TASK: There is no VB equivalent to the C# 'null-forgiving operator':
'ORIGINAL LINE: Rectangle rectangle = new Rectangle((int)x1, (int)y1, (int)barcode.Width!, (int)barcode.Height!);
Dim rectangle As New Rectangle(CInt(Math.Truncate(x1)), CInt(Math.Truncate(y1)), CInt(barcode.Width), CInt(barcode.Height))
bitmap = bitmap.Redact(rectangle, Color.Magenta)
' Save the image
bitmap.SaveAs("redacted.png", AnyBitmap.ImageFormat.Png)
Next barcode
using IronBarCode;using System;// Read barcode from PDFBarcodeResults result = BarcodeReader.ReadPdf("test.pdf");// Output page number to consoleforeach (BarcodeResult barcode in result){Console.WriteLine("The barcode value " + barcode.ToString() + " is found on page number " + barcode.PageNumber);}
using IronBarCode;
using System;
// Read barcode from PDF
BarcodeResults result = BarcodeReader.ReadPdf("test.pdf");
// Output page number to console
foreach (BarcodeResult barcode in result)
{
Console.WriteLine("The barcode value " + barcode.ToString() + " is found on page number " + barcode.PageNumber);
}
ImportsIronBarCodeImportsSystem' Read barcode from PDFPrivate result AsBarcodeResults = BarcodeReader.ReadPdf("test.pdf")' Output page number to consoleFor Each barcode AsBarcodeResultIn resultConsole.WriteLine("The barcode value " & barcode.ToString() & " is found on page number " & barcode.PageNumber)Next barcode
Imports IronBarCode
Imports System
' Read barcode from PDF
Private result As BarcodeResults = BarcodeReader.ReadPdf("test.pdf")
' Output page number to console
For Each barcode As BarcodeResult In result
Console.WriteLine("The barcode value " & barcode.ToString() & " is found on page number " & barcode.PageNumber)
Next barcode
上記のコードスニペットは、ユーザーがプログラムに対し、複数ページのPDF文書内にあるBarCodeのvalueおよびそれぞれのページ番号を返すよう求めるユースケースの一例を示しています。 このコードは、複数ページのPDFドキュメント内のBARCODEを読み取るためにBarcodeResultsオブジェクトを返します。 ループを適用し、オブジェクト内の各項目を反復処理して、BARCODEの value およびBARCODEが見つかったページ番号を取得します。 このユースケースとは別に、ユーザーはこのプロパティを使用して、ドキュメント内のすべてのBARCODEが読み取られたかどうかをデバッグすることができます。
Using IronBarcode, users can retrieve information about the barcode orientation and the orientation of the page where the barcode was detected. これら2つの情報を抽出するには、BarcodeResult オブジェクトから Rotation および PageOrientation プロパティにアクセスしてください。 Rotation は、検出された BARCODE の回転角度を表す整数を返します。 この機能は、画像の向き補正機能と連携して動作し、スキャン角度にかかわらず正確なBARCODE読み取りを保証します。
以下のコードスニペットをご覧ください:
using IronBarCode;using System;// Read barcode from PDFBarcodeResults result = BarcodeReader.ReadPdf("test.pdf");// Output page orientation and rotation to consoleforeach (BarcodeResult barcode in result){Console.WriteLine(barcode.Value);Console.WriteLine(barcode.PageOrientation);Console.WriteLine(barcode.Rotation);}
using IronBarCode;
using System;
// Read barcode from PDF
BarcodeResults result = BarcodeReader.ReadPdf("test.pdf");
// Output page orientation and rotation to console
foreach (BarcodeResult barcode in result)
{
Console.WriteLine(barcode.Value);
Console.WriteLine(barcode.PageOrientation);
Console.WriteLine(barcode.Rotation);
}
ImportsIronBarCodeImportsSystem' Read barcode from PDFPrivate result AsBarcodeResults = BarcodeReader.ReadPdf("test.pdf")' Output page orientation and rotation to consoleFor Each barcode AsBarcodeResultIn resultConsole.WriteLine(barcode.Value)Console.WriteLine(barcode.PageOrientation)Console.WriteLine(barcode.Rotation)Next barcode
Imports IronBarCode
Imports System
' Read barcode from PDF
Private result As BarcodeResults = BarcodeReader.ReadPdf("test.pdf")
' Output page orientation and rotation to console
For Each barcode As BarcodeResult In result
Console.WriteLine(barcode.Value)
Console.WriteLine(barcode.PageOrientation)
Console.WriteLine(barcode.Rotation)
Next barcode
もちろん、IronBarcodeを使用する際にユーザーが取得したい主なプロパティは、その value および text です。 これら2つのプロパティはしばしば同じ意味で使用され、同じvalueを返します。 それとは別に、ユーザーは BarcodeResult.ToString() メソッドを使用することで、同様の結果を得ることができます。 専門的なアプリケーションでの作業や、BARCODEデータをストリームとしてエクスポートする際、これらのプロパティを利用することで、お好みの形式でBARCODEの内容に柔軟にアクセスできます。
以下のコードスニペットはその一例です:
using IronBarCode;using System;// Read barcode from PDFBarcodeResults result = BarcodeReader.ReadPdf("barcodestamped3.pdf");// Output text value to consoleforeach (BarcodeResult barcode in result){Console.WriteLine(barcode.Value);Console.WriteLine(barcode.Text);Console.WriteLine(barcode.ToString());}
using IronBarCode;
using System;
// Read barcode from PDF
BarcodeResults result = BarcodeReader.ReadPdf("barcodestamped3.pdf");
// Output text value to console
foreach (BarcodeResult barcode in result)
{
Console.WriteLine(barcode.Value);
Console.WriteLine(barcode.Text);
Console.WriteLine(barcode.ToString());
}
ImportsIronBarCodeImportsSystem' Read barcode from PDFPrivate result AsBarcodeResults = BarcodeReader.ReadPdf("barcodestamped3.pdf")' Output text value to consoleFor Each barcode AsBarcodeResultIn resultConsole.WriteLine(barcode.Value)Console.WriteLine(barcode.Text)Console.WriteLine(barcode.ToString())Next barcode
Imports IronBarCode
Imports System
' Read barcode from PDF
Private result As BarcodeResults = BarcodeReader.ReadPdf("barcodestamped3.pdf")
' Output text value to console
For Each barcode As BarcodeResult In result
Console.WriteLine(barcode.Value)
Console.WriteLine(barcode.Text)
Console.WriteLine(barcode.ToString())
Next barcode
IronBarcodeを使用すると、次のように1行でバーコードを読み取ることができます: var result = IronBarCode.BarcodeReader.Read('input.png'); これですぐにresult[0].Valueとresult[0].BarcodeTypeを通してバーコードの値とタイプにアクセスできます。
What kind of applications benefit from using IronBarcode's output data formats?
Applications in inventory management, document processing, and quality control greatly benefit from IronBarcode's diverse data formats as they offer extensive barcode data processing options.
Can IronBarcode read barcodes from multipage PDF documents?
Yes, IronBarcode can read barcodes from multipage PDF documents using methods like `BarcodeReader.ReadPdf()`, which also informs about the page number on which each barcode is found.