Code 128
16 commentaires
I like the idea of the barcode fonts, they print ok, but the barcode reader cannot decipher them, Am I doing something wrong?
Grand Zebu, you rock!!!
You just saved my life man. If there's a way to donate some money, please let me know.
Thanks a lot dude
The Code 128 symbology has particular start and stop characters and a check sum. Look on Wikipedia or Google for Code 128 to find the "rules".
Hi nibblesmx,
I want to print bar code - Code128 font with the following data.
123 ABC
the data contains space in between and code 128 does not support. can anybody help me?
Thanks.
Pushkar
Hi. I used these fonts but barcode are not identified by the barcode reader. As "rjskoko" said must include the start and stop characters. In wikipedia say that start character in code 128 C is the ascii code 210 but how can I type it? Also as I see there isn't barcode for this ascii in the fonts!
They do not work. The stop character Î (ASCII 206) is not the same as it appears to this web page!!!
I've implemented this font to print voucher codes, I choose Code 128 B but when the result of the checksum is a character for example 127, it prints a white square. This is part of the code that I wrote. This code works for me, most of times.
Private Sub onPrint(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
Dim printFont As New Font("code 128", 40)
Dim stringToBarCode As String = "251250000156"
Dim intChar As Integer
Dim stringBuild As New StringBuilder
Dim checksum As Integer = 104
Dim i As Integer = 1
Dim crcResult As Integer
stringBuild.Append(ChrW(204))
For Each c As Char In stringToBarCode.ToCharArray
intChar = Encoding.ASCII.GetBytes(c)(0)
If intChar >= 32 And intChar <= 126 Then
checksum += (intChar - 32) * i
i += 1
stringBuild.Append(c)
End If
Next
If checksum > 104 Then
crcResult = (checksum Mod 103) + 32
stringBuild.Append(ChrW(crcResult))
stringBuild.Append(ChrW(206))
ev.Graphics.DrawString(stringBuild.ToString, printFont, Brushes.Black, 1, 1)
End If
End Sub
How can it be solved?, Do I need to edit the font? if so, how can i do it?
this has no characters for start, and stop codes.
Start A is ascii 208, start B is ascii 209 and start c ascii 210. The stop code is allways 211. All these characters are not available with this font...
Help me please, i printed card with id but don´t put start, stop codes or digi controller, and then the reader can´t read my codebar, exist a solution ?
Help me please, i printed card with id but don´t put start, stop codes or digi controller, and then the reader can´t read my codebar, exist a solution ?
Thanks to David Aguilar and the info on Wikipedia I fixed the code to use this font. (Below the c# code)
public string Code128(string toEncode)
{
StringBuilder Encoded = new StringBuilder();
//Start code
Encoded.Append((char)204);
int sum = 104;
for (int i = 0; i < toEncode.Length; i++)
{
sum += ((char)toEncode[i] - 32) * (i+1);
Encoded.Append(toEncode[i]);
}
sum = sum % 103;
sum += 32;
//Checksum between 94 and 103 are encoded in the 200 - 206 range
if (sum > 94 && sum < 103)
sum += 105;
//Checksum
Encoded.Append((char)sum);
//Stop code
Encoded.Append((char)206);
return Encoded.ToString();
}
The Difference with the code of David is that if the checksum values is in the 95-102 we have the correct font on ASCII (200-207). I made several test and it works.
Hello, CirasaEric. Thanks for the code. Could you please give us instructions on how to use this code. When I try to use putting it in a macro it give me a sintax error.
Your help will be really appreciated.