In this web programming tutorial we will learn that how we can generate barcode in asp.net using c#, as it is often used in different projects and web developers have to face problem, see the below code and just copy and past in your page.
Code for .CS file
Code for .CS file
using System; using System.Data; using System.Drawing.Imaging; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using Bytescout.BarCode; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { // Create new barcode Barcode barcode = new Barcode(); // Set symbology barcode.Symbology = SymbologyType.Code39; // Set value barcode.Value = "Sample"; // Clear http output Response.Clear(); // Set the content type to PNG Response.ContentType = "image/png"; // Add content type header Response.AddHeader("Content-Type", "image/png"); // Set the content disposition Response.AddHeader("Content-Disposition", "inline;filename=result.png"); // Save image to output stream barcode.SaveImage(Response.OutputStream, ImageFormat.Png); // End response Response.End(); } }
1 comment:
I use Aspose.Barcode for .NET Library for generating barcode images because it gives me alot of option to export my barcode in many image formats including BMP, EMF, GIF, JPEG, PNG, TIFF and WMF. This library offers many other features, you should try this library.
http://www.aspose.com/.net/barcode-component.aspx
Post a Comment