IronBarcode MSI Barkodu Tanıyamadı

This article was translated from English: Does it need improvement?
Translated
View the article in English

Sorun

IronBarcode kütüphanesini kullanarak bir MSI BARCODE oluştururken, BarcodeReader.Read yönteminin oluşturulan MSI BARCODE'u okuyamadığı durumlar olabilir; bu da taramanın boş çıkmasına ve BARCODE'dan beklenen değerin alınamamasına neden olur.

Çözüm

BarcodeReader.Read'nin MSI BARCODE'ını okuyabilmesini sağlamak için, Read yöntemi için ikincil isteğe bağlı BarcodeReaderOptions parametresini sağlamalıyız. BarcodeReaderOptions içinde, ExpectedBarcodeTypes değerini atayarak okumaya çalıştığımız BarCode türünü açıkça belirtiriz. Bu şekilde, Read yöntemi, IronBarcode'dan oluşturulan MSI BarCode'un yanı sıra herhangi bir harici MSI BarCode'u da tanıyacaktır.

Aşağıda, BarcodeReaderOptions'nin BarcodeReader.Read'ye nasıl uygulanacağına dair kısa bir örnek verilmiştir.

Kod Örneği

// Creating MSI Barcode with the value "12345"
var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.MSI);

// Save barcode as image
myBarcode.SaveAsImage("msi.png");

// Reading MSI
var barcodeReaderOptions = new BarcodeReaderOptions
{
     // Assigning BarcodeEncoding.MSI to ExpectBarcodeType to ensure that IronBarcode expects MSI type barcodes specifically 
  ExpectBarcodeTypes = BarcodeEncoding.MSI,
};

// Read barcode with additional barcodeReaderOptions from above
var barcodeResults = BarcodeReader.Read("msi.png", barcodeReaderOptions);

// Using a for loop and print out the result 
foreach (BarcodeResult result in barcodeResults)
{
  Console.WriteLine(result.Text);
    // Output: 12345 
}
// Creating MSI Barcode with the value "12345"
var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.MSI);

// Save barcode as image
myBarcode.SaveAsImage("msi.png");

// Reading MSI
var barcodeReaderOptions = new BarcodeReaderOptions
{
     // Assigning BarcodeEncoding.MSI to ExpectBarcodeType to ensure that IronBarcode expects MSI type barcodes specifically 
  ExpectBarcodeTypes = BarcodeEncoding.MSI,
};

// Read barcode with additional barcodeReaderOptions from above
var barcodeResults = BarcodeReader.Read("msi.png", barcodeReaderOptions);

// Using a for loop and print out the result 
foreach (BarcodeResult result in barcodeResults)
{
  Console.WriteLine(result.Text);
    // Output: 12345 
}
' Creating MSI Barcode with the value "12345"
Dim myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.MSI)

' Save barcode as image
myBarcode.SaveAsImage("msi.png")

' Reading MSI
Dim barcodeReaderOptions As New BarcodeReaderOptions With {.ExpectBarcodeTypes = BarcodeEncoding.MSI}

' Read barcode with additional barcodeReaderOptions from above
Dim barcodeResults = BarcodeReader.Read("msi.png", barcodeReaderOptions)

' Using a for loop and print out the result 
For Each result As BarcodeResult In barcodeResults
  Console.WriteLine(result.Text)
	' Output: 12345 
Next result
$vbLabelText   $csharpLabel

Örnekte, önce yeni bir BarcodeReaderOptions değişkeni oluşturuyoruz, ardından ExpectedBarcodeTypes'ye BarcodeEncoding.MSI enum'unu atayarak IronBarcode'a bunun yerine MSI BarCode'unu beklemesi talimatını veriyoruz. Ardından, barcodeResults bir BarcodeResults dizisi döndürdüğü için, bir for döngüsü içinde BARCODE'un değerini (12345) PRINT ederiz ve metin değeri için her sonucu döngüye alırız.

Curtis Chau
Teknik Yazar

Curtis Chau, Bilgisayar Bilimleri alanında Lisans Derecesine (Carleton Üniversitesi) sahip ve Node.js, TypeScript, JavaScript ve React konularında uzmanlaşmış ön uç geliştirmeyle ilgileniyor. Sezgisel ve estetik açıdan hoş kullanıcı arayüzleri oluşturma tutkunu, Curtis modern çerçevelerle çalışmayı ve iyi yapı...

Daha Fazla Oku
Başlamaya Hazır mısınız?
Nuget İndirmeler 2,240,258 | Sürüm: 2026.5 just released
Still Scrolling Icon

Hâlâ Kaydırıyor Musunuz?

Hızlıca kanıt ister misiniz? PM > Install-Package BarCode
bir örnek çalıştır dizginizin barkoda dönüştüğünü izle.