Coldfusion Code128 barcode problem

Ok so I have to say right off the bat, I don't know much about barcoding. I did manage to get the code working to generate and size the barcode.

My problem is that the barcode width seems to change based on the number of characters in the code. I didn't think this was a problem initially but as I started testing on our equipment I found a pretty big problem.

The barcodes with 4 digits (7512 from my test) scanned perfect with the following code. Barcodes with 5 digits (12206 from my test) will not scan. If you look at the ID's they are in the exact same position on the card. Same distance from the bottom and top. It looks like when i use the 5 digit number its scaling from the middle out. The heights of the barcodes stay the same just the width changes equally on both sides.

Here is the code i use to generate the barcode and I'm wondering is there any way to keep the barcode sizes exactly the same so they will both snap the same. Is there a property i can set for this? Is my code wrong? Anything?

Barcode = createObject("java", "net.sourceforge.barbecue.linear.code128.Code128Barcode").init(#Participant_ID__c#);
BarcodeImageHandler = createObject("java", "net.sourceforge.barbecue.BarcodeImageHandler");


<!--- extract the buffered image of the bar code --->
<cfset Handler = createObject("java", "net.sourceforge.barbecue.BarcodeImageHandler")>  
<cfset BuffImg = Handler.getImage( Barcode ) />  
<!--- use it create a CF image object --->
<cfset CFImageObject = ImageNew(buffImg) />  
<!--- do whatever you want with the image object --->
<cfimage source="#CFImageObject#" action="write" overwrite="Yes" destination="C:\inetpub\wwwroot\barcodes\#Participant_ID__c#.jpg"> 

Open in new window

Thanks for your help
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Take a look at the following CF Barcode Generator. It appears not rely on any external libraries. Unfortunately, I could verify that because the source is encrypted...

It appears to handle also handle Code128 Character sets as well.
joedfuseAuthor Commented:
Nah, i dont want to buy a tag. Im sure I can figure out something with mine. I mean like I said mine works i just dont understand why the barcode changes sizes due to number of digits

It looks like when i use the 5 digit number its scaling from the middle out.

Can you test using 6,7,8, and 9 digits? Is there an error on odd versus even digits?
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

joedfuseAuthor Commented:
I am not receiving any errors.  Just width changing depending on the number length.  Very strange. No change in height
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Could you somehow provide a screenshot of the good and bad barcodes? That might help.
@joedfuse - After reviewing some different sites about Code 128 Barcodes, I come to the conclusion that the changing width is a just result of how the 128 specification performs the binary encoding of your input string. For example, sequences of zeros or ones simply appear as thicker bars or spaces. Which, may impact the barcode width when using the 128 Code specification.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
joedfuseAuthor Commented:
Thanks, I came to similar conclusion and decided it was worth upgrading our hardware since we only need to replace a few scanners.
Yes, it's just the way the encoding works.  You can't set explicit dimensions because forcing a bar code fit inside those dimensions might make it invalid according to the specs. It's why the library doesn't offer explicit setWidth/setHeight methods ;-)  Since the BBQ library is well established,  sounds like the equipment is more likely to be the culprit here.
joedfuseAuthor Commented:
Here is a question i was wondering .... Does the space around the barcode affect scanning? I am noticing even with the new equip it doesn't really like the wide barcode that is closer to other text than the narrow ones.

@joedfuse - I haven't come across anything that explicitly mentions space tolerances for CODE 128 barcodes, but anything that skews tolerance level can impact your scanning.

The following FedEx document has some good information on UCC/EAN CODE 128 “SSCC-18” specifications

This article mentions error tolerance failure in a barcode's quiet zone. A quiet zone is the blank margin on either side of a bar code that's used to tell the barcode reader where a barcode's symbology starts and stops.
>>  barcode's quiet zone

That's also something you can check.  IIRC, quiet zone is enabled by default.  Check the dimensions compared to barwidth/height set in code.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.