What would cause Code128 barcodes generated from the netbarcodewriter library not to scan?

StackOverflow https://stackoverflow.com//questions/20045056

  •  26-12-2019
  •  | 
  •  

Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top