1D Barcode Reader voor .NET
Inleiding tot 1D Barcode Reader voor .NET
De 1D Barcode Reader voor .NET is een krachtig plug-in dat ontwikkelaars in staat stelt om te lezen en te decoderen 1d barcode van afbeeldingen. deze gids zal je door de functies en mogelijkheden van de plugin, het verstrekken van code voorbeelden in C# om u te helpen beginnen.
Ondersteunde barcode symbolen
De 1D Barcode Reader voor .NET ondersteunt een breed scala aan 1d barcode symbolen, waaronder:
- UPC-A
- UPC-E
- Hoofdstuk 13
- De EAN-8
- De code 39
- De code 93
- De code 128
- Interleaved 2 van 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 lezen van afbeeldingen
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];
U kunt ook barcodes lezen van streams:
// 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];
}
Decoderen van 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;
Foutbehandeling
De 1D Barcode Reader voor .NET gooit uitzonderingen als er een fout optreedt tijdens het lezen of decoderen van de 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);
}