Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Oct 19, 2012 03:30 AM by popperyhooop
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..
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");
string imgpath = s_refnum + ".png";
Session["imgpath"] = imgpath;
using (MemoryStream ms = new MemoryStream())
byte byteImage = ms.ToArray();
imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
Oct 10, 2012 12:13 PM|LINK
You should take this issue up with the barcode scanner supplier.
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
string barCode = "*" + s_refnum + "*";
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
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.
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 + ")";
Oct 19, 2012 03:30 AM|LINK