the start/stop character is required for your 3of9 barcode image to be valid... and the technique you're using (a barcode font) prints the * character along with it's bars. if you stick with that font, your stuck
with the asterisk.
3of9 is a pretty simply barcode so you could draw it (GDI) without the font. or you might take look at a using iTextsharp. iTextsharp is well known for its pdf generation capabilities, but it also contains functionality to generate barcode images.
EDIT - looks like that font you're using also offers alternate start/stop chars using ( and ) . those print the start/stop bars but have no textual output.
popperyhooop
Member
68 Points
195 Posts
GEnerated Barcode dont scan in barcode scanner?
Oct 10, 2012 02:50 AM|LINK
hi any help, i dont know what is the problem why i cant scan the barcode i created in a barcode scanner? here is my code..
//barcode
string barCode = s_refnum;
System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
using (Bitmap bitMap = new Bitmap(barCode.Length * 35, 80))
{
using (Graphics graphics = Graphics.FromImage(bitMap))
{
System.Drawing.Font oFont = new System.Drawing.Font("IDAutomationHC39M", 16);
PointF point = new PointF(2f, 2f);
SolidBrush blackBrush = new SolidBrush(System.Drawing.Color.Black);
SolidBrush whiteBrush = new SolidBrush(System.Drawing.Color.White);
graphics.FillRectangle(whiteBrush, 0, 0, bitMap.Width, bitMap.Height);
graphics.DrawString(barCode, oFont, blackBrush, point);
Response.ContentType = "image/jpeg";
string s_path = Server.MapPath("images/barcode/" + s_refnum + ".jpeg");
bitMap.Save(s_path, ImageFormat.Jpeg);
string imgpath = s_refnum + ".png";
Session["imgpath"] = imgpath;
}
using (MemoryStream ms = new MemoryStream())
{
bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
byte[] byteImage = ms.ToArray();
Convert.ToBase64String(byteImage);
imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
}
}
Mikesdotnett...
All-Star
154941 Points
19870 Posts
Moderator
MVP
Re: GEnerated Barcode dont scan in barcode scanner?
Oct 10, 2012 12:13 PM|LINK
You should take this issue up with the barcode scanner supplier.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
mbanavige
All-Star
134971 Points
15423 Posts
ASPInsiders
Moderator
MVP
Re: GEnerated Barcode dont scan in barcode scanner?
Oct 18, 2012 12:51 PM|LINK
Also keep in mind that code 39 requires start/stop characters. in code 39, the asterisk represents the start/stop
i.e.
string barCode = "*" + s_refnum + "*";
popperyhooop
Member
68 Points
195 Posts
Re: GEnerated Barcode dont scan in barcode scanner?
Oct 19, 2012 01:56 AM|LINK
yeah. i put an "*" but when i save it it appears. how can i make it not to appear on my barcode image created? thanks
mbanavige
All-Star
134971 Points
15423 Posts
ASPInsiders
Moderator
MVP
Re: GEnerated Barcode dont scan in barcode scanner?
Oct 19, 2012 02:20 AM|LINK
the start/stop character is required for your 3of9 barcode image to be valid... and the technique you're using (a barcode font) prints the * character along with it's bars. if you stick with that font, your stuck with the asterisk.
3of9 is a pretty simply barcode so you could draw it (GDI) without the font. or you might take look at a using iTextsharp. iTextsharp is well known for its pdf generation capabilities, but it also contains functionality to generate barcode images.
http://sourceforge.net/projects/itextsharp/
EDIT - looks like that font you're using also offers alternate start/stop chars using ( and ) . those print the start/stop bars but have no textual output.
string barCode = "(" + s_refnum + ")";
popperyhooop
Member
68 Points
195 Posts
Re: GEnerated Barcode dont scan in barcode scanner?
Oct 19, 2012 03:30 AM|LINK