How do you display bar code image on html

Hey,

VERY new to this stuff, which is why I just joined.    Please excuse my ignorance,
I've been given a project to add a bar code (Interleaved 2 of 5) to an existing html that is displayed on a web site.  The site will be visited by several people at the same time.  They will enter a unique number to identify themselves and this needs to be converted and displayed once the information is retreived.  Also this barcode will need to be deleted once the user exits the site.
I found some code online that will do the conversion and will display that image on the screen, I just need to incorporate that into the existing app.  The problem I'm having is how to store and display this on the html.  I guess I'm not grasping the virtual path concept I've seen in other examples.  Also is there a free version of this barcode format, I've not been able to find one?
I work for a cheap company!

There are images being displayed from this folder, C:\inetpub\wwwroot\edocs\images and code behind that defines and displays one of them.

public String VOUCHERS_IMG;
eimages.VOUCHERS_IMG = GetText(ref dr, "VOUCHERS_IMG_TXT");
String voucher_img = "";
        voucher_img = "<img src=\"images/" + eimages.VOUCHERS_IMG + "\" alt=\"Voucher section\" />";
eimages.VOUCHERS_IMG = GetText(ref dr, "VOUCHERS_IMG_TXT");

Thanks in advance, and sorry for the long winded first question.

This is an example of code I was referring to if you have something better that would be great:

BCGFont font = new BCGFont(new Font("Arial", 10, FontStyle.Regular));
             BCGColor color_black = new BCGColor(0, 0, 0);
             BCGColor color_white = new BCGColor(255, 255, 255);

             BCGBarcode1D code = new BCGi25();
             code.setScale(2); // Resolution 
             code.setThickness(15); // Thickness 
             code.setForegroundColor(color_black); // Color of bars 
             code.setBackgroundColor(color_white); // Color of spaces 
             code.setFont(font); // Font
             code.setChecksum(true);
             code.parse(res_id.ToString()); // Text 

             BCGDrawing drawing = new BCGDrawing(null, color_white);
             drawing.setBarcode(code);
             drawing.draw();

             Draw (or save) the image into PNG format. Bmp, jpeg, gif 
             Response.ContentType = "image/png";
             Response.TransmitFile();
             drawing.finish(ImageFormat.Png, Response.OutputStream);
or
        private void GenerateBarCode(string codeInfo) //codeInfo is the info which you want to barcoded.
        {
            //Settings for the Image
            string TypeFaceName = "IDAutomationHC39M"; // this is the name of font from which your barcode is generated.
            string imageLocation = Server.MapPath("Path of Image on which you want to generate it");
           
            //The format of the image file
            ImageFormat format = ImageFormat.Png;

            //path of unique file name   
            //string path = "~/images/barcodes/" + txt + "_" + DateTime.Now.ToFileTimeUtc().ToString() + ".jpg";    
            string path = string.Format("{0}{1}.png", PathOf where you want to save the Barcode generated image, codeInfo);

            //REFERENCING A FONT 
            PrivateFontCollection fnts = new PrivateFontCollection();
            fnts.AddFontFile("IDAutomationHC39M.ttf");// this is the name of font from which your barcode is generated.
            FontFamily fntfam = new FontFamily(TypeFaceName, fnts);
            Font fnt = new Font(fntfam, 10);
            fnts.AddFontFile("Arial.ttf");
            FontFamily fntfam2 = new FontFamily("Arial", fnts);

            //DRAWING THE IMAGE  
            Bitmap bmp = new Bitmap(960, 386);           //Canvas size
            Graphics g = Graphics.FromImage(bmp);
            Bitmap origBitmap = new Bitmap(imageLocation);
            g.Clear(Color.Transparent); //Background color
            SizeF bc = g.MeasureString(codeInfo, fnt);
            Brush br = new SolidBrush(Color.Black);
            g.DrawImage(origBitmap, 10, 8);
            g.DrawString(codeInfo, fnt, br, 585, 170); //Drawing the Image
            bmp.Save(path, format); //Saving the Image file
            bmp.Dispose(); //Releasing all resources (Image file) 
            Response.Clear();
        }

Open in new window

umcanesfanAsked:
Who is Participating?
 
Michel PlungjanIT ExpertCommented:
Hi umcanesfan and welcome to EE
No problem being long winded at all. The more information we get the better.
However a suggestion is to click the "CODE" link next time and paste the code into the field that appears. I have moved your code there for you (because I can - I am Zone Advisor and more)
I also added the ASP zone to get some more experts to look at your issue

To COMMENT on your question (since I am not and asp person)
It would be interesting to know if you are aware that showing an image on a web page requires TWO calls to the server, one is the html
<img src="....">
and the second is to request what is in the src="....."
So your html could typically look like

<img src="getBarCode.asp?someId=<%= userID %>" />
where the userId is the code you received from the user in the previous screen

Good luck

Michel
0
 
Michael701Commented:
you library saves the image to the server's hard drive
 bmp.Save(path, format); //Saving the Image file


so in the html you'd simple display this image
0
 
Michel PlungjanIT ExpertCommented:
BMP would not be an optimal image format - far too large.
jpg, png or gif would be much preferrable
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
tncodeCommented:
If you don't want to save the image to your hard drive or use fonts, try a streaming server, such as the www.bcgen.com site, for example http://www.bcgen.com/demo/linear-dbgs.aspx?D=123456789012
0
 
Michael701Commented:
AS for the image format. I was just commenting on the existing library code. I agree gif would probably be the smallest image size because you can set the max colors to 2.

With a quick modification (or maybe it's already part of the library) this code could display the image inline.
0
 
Michel PlungjanIT ExpertCommented:
That is what the first code is doing:

http://barcodeasp.com/1d/manual.php?ns=BarcodeGenerator.WebControls&id=BCGi25

for full version
0
 
umcanesfanAuthor Commented:
I would like to re-phrase and re-submit this question.  The solution is still not totally clear, due to nobody's fault but mine.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.