How do you display bar code image on html


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.parse(res_id.ToString()); // Text 

             BCGDrawing drawing = new BCGDrawing(null, color_white);

             Draw (or save) the image into PNG format. Bmp, jpeg, gif 
             Response.ContentType = "image/png";
             drawing.finish(ImageFormat.Png, Response.OutputStream);
        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);
            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) 

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Michel PlungjanIT ExpertCommented:
BMP would not be an optimal image format - far too large.
jpg, png or gif would be much preferrable
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

If you don't want to save the image to your hard drive or use fonts, try a streaming server, such as the site, for example
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.
Michel PlungjanIT ExpertCommented:
That is what the first code is doing:

for full version
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.