Link to home
Start Free TrialLog in
Avatar of joedfuse
joedfuseFlag for United States of America

asked on

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?

<cfscript>
Barcode = createObject("java", "net.sourceforge.barbecue.linear.code128.Code128Barcode").init(#Participant_ID__c#);
BarcodeImageHandler = createObject("java", "net.sourceforge.barbecue.BarcodeImageHandler");
Barcode.setDrawingText(false);
Barcode.setBarHeight(30);
Barcode.setBarWidth(2);

</cfscript>

<!--- 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
Avatar of LajuanTaylor
LajuanTaylor

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... http://www.webcaterers.com/barcodes/default.cfm?NavBar=ShowMe

It appears to handle also handle Code128 Character sets as well.
Avatar of joedfuse

ASKER

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

Thanks
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?
I am not receiving any errors.  Just width changing depending on the number length.  Very strange. No change in height
Avatar of mccarl
Could you somehow provide a screenshot of the good and bad barcodes? That might help.
ASKER CERTIFIED SOLUTION
Avatar of LajuanTaylor
LajuanTaylor

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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.

Thanks
@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
http://images.fedex.com/us/solutions/ppe/FedEx_Ground_Label_Layout_Specification.pdf

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.
http://www.barcode-test.com/barcode-advice/barcode-error-tolerance/
>>  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.