3

I'm trying to use the netbarcodewriter from https://github.com/simongh/barcodes to generate code128 barcodes. The barcode generated can only be scanned by some smartphone apps, but not from any USB scanners or ruggedized windows mobile 6 scanners we have.

For example the attached images show "502337700000000198" encoded from different sources, only 1 (ios) smartphone app - Zbarcode can scan the barcode generated by netbarcodewriter 1, others (attscanner) can't. None of the usb scanners or ruggedised windows ce terminals scan it either.

from netbarcodewriter

from raco

from itextsharp

string huid = "502337700000000198";

short w = 251;
short h = 100;
short x = 28;
Code128 code = new Code128();

var b2mp = code.Generate(huid, new BarcodeSettings { BarHeight = 65, WideWidth = w - 2 * x });
b2mp.Save(string.Format(@"c:\temp\{0}.png", huid), ImageFormat.Png);

When generated by itextsharp 3 or on sites like racoindustries.com/barcodegenerator/1d/code-128.aspx 2, all the scanners work. iTextSharp's barcode is just too small, and the BarcodeSize property can't be set.

Has any one worked with this library? Also, does anyone know what those #MARKER grey rectangles do?

Any help will be appreciated.

reckface
  • 5,678
  • 4
  • 36
  • 62
  • the #marker grey rectangles are a debug feature to allow you to read the barcode by eye easier. They shouldn't be used in production – Simon Halsey Nov 22 '13 at 01:57
  • 1
    A quick look by eye & looks like the widths are off slightly in the top image. I'll see if I can figure out why – Simon Halsey Nov 22 '13 at 02:03
  • Thanks. I used an image editing tool to "make them fit" and I noticed that every third space was too wide. Just every third space. – reckface Nov 22 '13 at 09:12

1 Answers1

3

It's a sort of bug. When you create a new Code128 class, it sets it's default settings. for Code 128, this means setting module padding - the space between an encoded number - to 0.

In the code you've got above, you pass in a new settings object. This sets the padding back to it's default of 2, hence the extra spacing.

You're also setting the WideWidth. This isn't used in Code128 - it only uses NarrowWidth These are the width of the bars & default to 2.

Simon Halsey
  • 5,459
  • 1
  • 21
  • 32