1D Barcode-Reader für .NET

Einführung in 1D Barcode Reader für .NET

Der 1D Barcode Reader für .NET ist ein leistungsstarkes Plugin, das Entwicklern erlaubt, zu lesen und zu dekodieren 1d Barcodes aus Bildern. Dieser Leitfaden wird Sie durch die Funktionen und Fähigkeiten des Plugs, bietet Code Beispiele in C#, um Ihnen zu helfen, beginnen.

Unterstützte Barcode-Symbolen

Der 1D Barcode Reader für .NET unterstützt ein breites Spektrum von Symbolen für 1d-Barcode, darunter:

  • Die UPC-A
  • UPC-E
  • Die EAN-13
  • EAN-8
  • Code 39
  • Der Code 93
  • Kode 128
  • Interleaved 2 von 5
  • Code 11

You can specify the symbology to read using the BarcodeReader class:

// Create a new instance of BarcodeReader
Aspose.BarCode.BarcodeReader reader = new Aspose.BarCode.BarcodeReader("image.png", Aspose.BarCode DecodeType.Code39);

// Read the barcode
Aspose.BarCode.Result result = reader.ReadBarCodes()[0];

Barcodes aus Bildern lesen

To read a barcode from an image, you can use the BarcodeReader class and specify the image file path or stream:

// Create a new instance of BarcodeReader
Aspose.BarCode.BarcodeReader reader = new Aspose.BarCode.BarcodeReader("image.png");

// Read the barcode
Aspose.BarCode.Result result = reader.ReadBarCodes()[0];

Sie können auch Barcodes aus Streams lesen:

// Create a new instance of BarcodeReader
using (System.IO.Stream stream = System.IO.File.OpenRead("image.png"))
{
    Aspose.BarCode.BarcodeReader reader = new Aspose.BarCode.BarcodeReader(stream);
    // Read the barcode
    Aspose.BarCode.Result result = reader.ReadBarCodes()[0];
}

Decodierung von Barcodes

The BarcodeReader class returns a Result object, which contains information about the decoded barcode, including the symbology, code text, and supplement:

// Create a new instance of BarcodeReader
Aspose.BarCode.BarcodeReader reader = new Aspose.BarCode.BarcodeReader("image.png");

// Read the barcode
Aspose.BarCode.Result result = reader.ReadBarCodes()[0];

// Get the symbology
string symbology = result.CodeType;

// Get the code text
string codeText = result.CodeText;

Fehlerbehandlung

Der 1D Barcode Reader für .NET verlässt Ausnahmen, wenn während des Barcodes Lesens oder der Dekodierung ein Fehler auftritt:

try
{
    // Create a new instance of BarcodeReader
    Aspose.BarCode.BarcodeReader reader = new Aspose.BarCode.BarcodeReader("image.png");

    // Read the barcode
    Aspose.BarCode.Result result = reader.ReadBarCodes()[0];
}
catch (Aspose.BarCode.BarcodeException ex)
{
    Console.WriteLine("Error reading barcode: " + ex.Message);
}
 Deutsch