เครื่องอ่านบาร์โค้ด 1D สำหรับ .NET

บทนําใน 1D Barcode Reader สําหรับ .NET

เครื่องอ่านบาร์โค้ด 1D สําหรับ .NET เป็นปลั๊กอินที่มีประสิทธิภาพที่ช่วยให้ผู้พัฒนาสามารถอ่านและ decode รหัสบอร์ด 1d จากภาพ คู่มือนี้จะช่วยให้คุณผ่านคุณสมบัติและความสามารถของ plugin ให้ตัวอย่างรหัสใน C# เพื่อช่วยคุณเริ่มต้น

รองรับสัญลักษณ์รหัสบาร์

เครื่องอ่านบาร์โค้ด 1D สําหรับ .NET สนับสนุนความหลากหลายของ Symbolics ของ Barcode 1d รวมถึง:

  • UPC-A
  • UPC-E
  • EAN-13
  • EAN-8
  • รหัส 39
  • รหัส 93
  • รหัส 128
  • Interleaved 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];

นอกจากนี้คุณยังสามารถอ่านรหัสบาร์จาก 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];
}

บาร์โค้ด decoding

อะไร BarcodeReader คลาสกลับ A 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 สําหรับ .NET จะยกเว้นหากเกิดข้อผิดพลาดในระหว่างการอ่านหรือ decoding:

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);
}
 แบบไทย