barcodelib icon indicating copy to clipboard operation
barcodelib copied to clipboard

Wide bar to narrow bar width

Open tinohager opened this issue 2 years ago • 9 comments

Hi, i am work on a Zebra Zpl Viewer in the zpl language it is possible to set the Wide bar to narrow bar width. I search a configuration for this. According to Zebra's documentation, it should be configurable on the following barcodes: Code 11, Interleaved 2 of 5, Standard 2 of 5, Code 39, ANSI Codabar, LOGMARS, MSI, Plessey

Do you have a suggestion for me how I could set this?

image

tinohager avatar Aug 18 '21 20:08 tinohager

So first of all, the picture that is rendered has only a 72dpi resolution per default I think. Set HoritontalResolution and VerticalResolution to what need or you end up with the wrong bar size later.

I´ve changed it to a 300dpi resolution picture and automatically calculated the width again when a bar was smaller than 1px. Sadly, I don´t have the code anymore. My ex-boss and I got in a fight and he locked my computer so I couldn´t get it off it, but I was already pretty much finished at that point.

But that was pretty much my solution for our Code128. Others could be rendered and calculated the same way. You have to get the payload and with that, the size of the barcode. The BarcodeLib.cs is the class you have to edit here. The symbologies are just the ones and zeros, or the payload that you need. Generate_Image() has to be changed a bit to calculate the final width and and the spacings plus the deadzone. I think the change is around line 580+.

You have to calculate the pen size for the 1 and 0 yourself. If you mix narrow and wide spacing, the final image width will change. I´ve never seen that in production tbh, we have Zebra Barcodes for many machines here and always have the same bar and space size.

Do the narrow and wide bars switch like: NB NS WB NS WB WS NB NS (what would be 10101010)

and what happens when you have 110100, would it be NB WB WS NB NS WS ?

At the end, a Barcode is like Morsecode.

LordPinhead avatar Aug 24 '21 06:08 LordPinhead

@LordPinhead How do you review Zpl labels or design new ones?

tinohager avatar Aug 25 '21 20:08 tinohager

I use the http://labelary.com/viewer.html online viewer, the Documentation of ZPL and just design them per hand. When I´m finished, I print a testlabel out manually and if everything is ok. I put in placeholders for the field data (FD) in the form of {MyVariable} and use it in our C# App.

That works for years now. This lib I use for the Code128 labels of my prior company and here, I use it for transport labels, which are printed manually aka via Crystal Reports and UPC for a machine here to start the appropriate programm.

LordPinhead avatar Aug 30 '21 05:08 LordPinhead

All bars are honestly the same width when encoded to 1s and 0s. Multiple 1s next to each other draw perceiveable wider bars even though the actual bar width is the same. Configuring bar width independent of each other like that does not sound like it would ever be valid.

barnhill avatar Sep 01 '21 01:09 barnhill

Maybe not, on Wikipedia, the Code 11 explanation says there are different bar widths for left, middle and right. How can a scanner read this though?

LordPinhead avatar Sep 01 '21 06:09 LordPinhead

We have some scanners here, I'll do some tests with them in the next few days and then report back here.

tinohager avatar Sep 01 '21 07:09 tinohager

I guess I should explain that how they are encoded is using a standard bar width. A wide bar is proportional to a narrow bar so narrow bar widths can be used to draw wide bars. Independent widths non-proportional to each other Im sure renders barcodes unreadable.

barnhill avatar Sep 01 '21 13:09 barnhill

In the Documentation of zebra is this information available

image

tinohager avatar Sep 01 '21 13:09 tinohager

I have dug quite deep into (old) barcodes lately, and this is what I think (I could be wrong):

BarcodeLib does not support varying the wide to narrow ratio of wide and narrow elements. It encodes bars and spaces as a string of ones and zeroes.

I do not really understand the original poster's issue, but I am guessing really really loose now: I think he is/was writing a ZPL emulator without access to the ZPL source and used BarcodeLib to generate the barcodes and did not get the exact result of what a ZPL printer generates.

From what I can see and understand in BarcodeLib the 2:1 wide to narrow ratio is fixed.

I just finished making my renderer (another lib not yet published) capable of adjusting for the Codabar in the original variant where the wide to narrow ratio varies between 3:1 and 2:1 for every code word to make code word widths constant. That wasn't easy.

rob313663 avatar Oct 18 '23 20:10 rob313663