Hello,
My requirement is to produce a barcode on some shipping labels that needs to follow certain sizing guidelines. Along with the size guidelines, the barcode must print with a high quality (i.e. sharp black and white bars).
For context, the barcode symbology is Code128. I have two barcodes to produce. One barcode will have 17 characters and be 55m wide by 25m high. An example is ‘10008688694055001’. The second barcode will have three characters (e.g. ‘035’) and be 25m wide by 25m high.
Through several days of trial and error, I am starting to get close to example labels I have been sent in terms of the size and print quality.
My code after such trial and error looks like this:
BarCodeBuilder builder = new BarCodeBuilder();
builder.setSymbologyType(Symbology.Code128);
builder.setCodeLocation(CodeLocation.None);
builder.setCodeText(data);
builder.setxDimension(1f);
builder.setyDimension(3.33f);
builder.setBarHeight(60f);
builder.getMargins().set(0, 0, 0, 0);
return builder.getBarCodeImage();
Finally with these settings, the print quality of the first (bigger) barcode looks OK. Although the barcode generated is slightly wider than the requirement (57m vs 55m), I think it will pass the testing.
The second barcode is almost the perfect size, but the print quality just isn’t as sharp as it should be. It’s not terrible, but the lines aren’t as thick and sharp as I would expect. Changing the x / y / height dimensions I can see clearly has an affect to not only the size, but crucially the barcode quality when it prints.
Can someone help explain (or point me in the direction of any articles) that explain exactly what x/y dimensions and bar height mean and how they work in relation to one another? My feeling is I could eventually stumble upon the right set of values for the smaller barcode to ensure the print quality is as expected - but hoping it will be quicker if I actually understand what these things are doing so can be more “scientific” in the values I am setting!
Thanks for any help.