FAQ TBarCode in Web Applications
How Can I Stream a Barcode Image to the Browser (Client)?
How Can I Stream a Barcode Image to the Browser (Client)?
With TBarCode it is possible to stream a barcode image (e.g. based on GET or POST parameters) back to the client.
You can take a look on our online barcode generator, where we do this exactly.
This URL streams a barcode image (Data Matrix with the word "TBarCode" encoded) back to the browser: http://barcode.tec-it.com/barcode.ashx
Please use this code snippet for TBarCode .NET as starting point in ASP.NET:
// first adjust the barcode properties of the myBarcode object (class Barcode) // then calculate the width and height of the code in Pixels (sample available on request) // then write the barcode image as stream to the browser as follows Bitmap image = myBarcode.DrawBitmap(width, height); image.SetResolution(dpi, dpi); Response.Clear(); Response.ContentType = "image/gif"; image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif); HttpContext.Current.ApplicationInstance.CompleteRequest(); image.Dispose();
The SDK setup contains the Barcode Generator ASP.NET web application (in the samples folder), which is able to stream images to the browser by utilizing the TBarCode .NET Barcode Generator Assembly. This application can be installed on your own web server as well.