Page 1 of 1

IndexOutOfBoundsException with german umlauts

Posted: Thu Sep 08, 2011 3:19 pm
by Document Partner

I get an exception " Index was outside the bounds of the array." when trying to encode an Aztec symbol with german umlauts.
Here is the C# code I am using:

Code: Select all

      var barcodeWriter = new Vintasoft.Barcode.BarcodeWriter ();
      barcodeWriter.Settings.Barcode = Vintasoft.Barcode.BarcodeType.Aztec;
      barcodeWriter.Settings.ProcessSpecialSymbols = true;

      var valueItems = new List<ValueItemBase> ();
      valueItems.Add (new TextValueItem (@"German

      barcodeWriter.Settings.ValueItems = valueItems.ToArray ();
      var outputImage = barcodeWriter.GetBarcodeAsBitmap ();

      return outputImage;
kind regards,
Roman Brandstetter

Re: IndexOutOfBoundsException with german umlauts

Posted: Fri Sep 09, 2011 9:50 am
by Yuri

TextValueItem may contain only symbols which are allowed for encoding in text mode.

The symbols like Ä, Ö, Ü and ß should be encoded in binary mode.

Utilize automatic selection of encoding mode by setting barcodeWriter.Settings.Value property at necessary value.

The following code illustrate how your text is automatically devided on 17 items for its correct encoding further:

Code: Select all

var barcodeWriter = new Vintasoft.Barcode.BarcodeWriter();
barcodeWriter.Settings.Barcode = Vintasoft.Barcode.BarcodeType.Aztec;

barcodeWriter.Settings.Value =
var outputImage = barcodeWriter.GetBarcodeAsBitmap();

// TEST (read)
var barcodeReader = new BarcodeReader();
barcodeReader.Settings.ScanBarcodeTypes = barcodeWriter.Settings.Barcode;

IBarcodeInfo barcodeInfo = barcodeReader.ReadBarcodes(outputImage)[0];

if (barcodeWriter.Settings.Value != barcodeInfo.Value)
    throw new ArgumentException();

foreach (ValueItemBase valueItem in barcodeInfo.ValueItems)
    Console.WriteLine(string.Format("[{0}] {1}", valueItem.GetType().Name,
Sincerely, Yuri

Re: IndexOutOfBoundsException with german umlauts

Posted: Fri Sep 09, 2011 10:15 am
by Document Partner

Thanks for the info. The Code is working now.

kind regards,