1

When attempting to create an GS1-128 barcode I encounter the following exception: there.are.illegal.characters.for.barcode.128.in.1

        iTextSharp.text.pdf.Barcode barcode = null;
        barcode = new Barcode128();
        barcode.CodeType = iTextSharp.text.pdf.Barcode.CODE128_UCC;
        barcode.GenerateChecksum = true;
        barcode.Code = code;
        using (var image = barcode.CreateDrawingImage(Color.Black, Color.White))
Terry Burton
  • 2,801
  • 1
  • 29
  • 41
AbstractLabs
  • 151
  • 1
  • 4

2 Answers2

1

After pulling down the source it looks like there might be a bug in the library the code calling into GetRawText. It will pass CodeSet Auto which fails the assertions in in the method. I determined the following to be an acceptable workaround:

        iTextSharp.text.pdf.Barcode barcode = null;
        barcode = new Barcode128();
        barcode.CodeType = iTextSharp.text.pdf.Barcode.CODE128_RAW;
        barcode.GenerateChecksum = true;
        barcode.Code = Barcode128.GetRawText(code, true, Barcode128.Barcode128CodeSet.C);
        using (var image = barcode.CreateDrawingImage(Color.Black, Color.White))
AbstractLabs
  • 151
  • 1
  • 4
0

code.Normalize(NormalizationForm.FormKC)

Worked for me. try this.