1D Читатель Штрих-кодов для .NET

Введение в 1D Barcode Reader для .NET

1D Barcode Reader для .NET является мощным плагином, который позволяет разработчикам читать и декодировать 1Д баркоды из изображений.Этот руководство пройдет через функции и возможности плугина, предоставляя примеры кода в C#, чтобы помочь вам начать.

Поддерживаемые символы баркода

1D Barcode Reader для .NET поддерживает широкий спектр символов баркода, включая:

  • УПК-А
  • УПК-Е
  • ЭН-13
  • ЭН-8
  • Кодекс 39
  • Кодекс 93
  • Код 128
  • Размещены 2 из 5
  • Кодекс 11

Вы можете определить симбологию для чтения, используя BarcodeReader Класс :

// 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];

Читать баркоды из изображений

Чтобы прочитать баркод с изображения, вы можете использовать BarcodeReader класс и указание файла изображения маршрута или потока:

// 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];

Вы также можете прочитать баркоды из потоков:

// 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];
}

Декодирование баркодов

И в BarcodeReader Класс возвращается к Result Объект, который содержит информацию о декодированном баркоде, включая символогию, текст кода и дополнение:

// 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;

Ошибка обработки

1D Barcode Reader для .NET выводит исключения, если при чтении или декодировании баркода возникает ошибка:

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);
}
 Русский