Czytnik kodów kreskowych 1D dla .NET
Wprowadzenie do 1D Barcode Reader dla .NET
1D Barcode Reader dla .NET jest potężnym wtyczkiem, który umożliwia programistom odczytanie i dekodowanie kodów rzęs 1d z obrazów.Ten przewodnik przejdzie przez funkcje i możliwości plugina, dostarczając przykłady kodu w C#, aby pomóc Ci zacząć.
Wspierane symbole kodów barowych
1D Barcode Reader dla .NET obsługuje szeroką gamę symbologii kodów rzęsowych, w tym:
- UPC-A
- UPC-E
- EW-13
- EAN-8
- Kod 39
- Kod 93
- Kod 128
- Interleaved 2 z 5
- Kod 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];
Czytanie kodów z obrazów
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];
Możesz również przeczytać kody barowe z strumieni:
// 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];
}
Dekodowanie barkodów
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;
błędy traktowania
1D Barcode Reader dla .NET wyrzuca wyjątki, jeśli błąd występuje podczas czytania lub dekodowania kodu paska:
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);
}