Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wide bar to narrow bar width #135

Open
tinohager opened this issue Aug 18, 2021 · 9 comments
Open

Wide bar to narrow bar width #135

tinohager opened this issue Aug 18, 2021 · 9 comments

Comments

@tinohager
Copy link

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

@LordPinhead
Copy link

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.

@tinohager
Copy link
Author

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

@LordPinhead
Copy link

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.

@barnhill
Copy link
Owner

barnhill commented Sep 1, 2021

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.

@LordPinhead
Copy link

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?

@tinohager
Copy link
Author

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

@barnhill
Copy link
Owner

barnhill commented Sep 1, 2021

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.

@tinohager
Copy link
Author

In the Documentation of zebra is this information available

image

@rob313663
Copy link
Contributor

rob313663 commented Oct 18, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants