Đầu đọc mã vạch 1D cho .NET

Giới thiệu về 1D Barcode Reader cho .NET

The 1D Barcode Reader for .NET là một plugin mạnh mẽ cho phép các nhà phát triển để đọc và giải mã các mã thanh 1d từ hình ảnh. hướng dẫn này sẽ đi qua các tính năng và khả năng của plugin, cung cấp ví dụ mã trong C# để giúp bạn bắt đầu.

Hỗ trợ Barcode Symbols

1D Barcode Reader cho .NET hỗ trợ một loạt các biểu tượng mã vạch 1d, bao gồm:

  • UPC-A
  • UPC-E
  • EAN-13
  • EAN - 8
  • Mã 39
  • Mã 93
  • Mã 128
  • Interleaved 2 trong 5
  • Mã 11

Bạn có thể xác định biểu tượng để đọc bằng cách sử dụng BarcodeReader lớp :

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

Đọc Barcodes từ hình ảnh

Để đọc mã thanh từ một hình ảnh, bạn có thể sử dụng BarcodeReader class and specify the image file path or stream: lớp và xác định con đường hoặc dòng file hình ảnh:

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

Bạn cũng có thể đọc mã thanh từ dòng chảy:

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

Xóa Barcodes

của The BarcodeReader Lớp A trở lại Result đối tượng, trong đó có thông tin về mã thanh bị mã hóa, bao gồm biểu tượng học, văn bản mã, và bổ sung:

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

Lỗi xử lý

1D Barcode Reader cho .NET đưa ra ngoại lệ nếu có lỗi xảy ra trong quá trình đọc hoặc giải mã mã barcode:

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);
}
 Tiếng Việt