Neodynamic Barcode Professional 3.0 for ASP.NET (WebControl)
Microsoft .NET Framework (any version)
Microsoft Visual Studio .NET (any version)
Generating high quality barcode images is great for printing scenarios. One problem here however, is that the output barcode image size is directly proportional to the number of pixels in the image (DPI); i.e. the more pixel resolution (DPI), the greater the file size.
For example, if you try to display an image at 600 DPI on a HTML page, then you'll see that the image will appear huge on the client's browser. That's because most display screen resolution works at 96 DPI.
The following guide provides you with a possible solution to this issue. The idea behind it is to generate the barcode at 600 DPI in the server side by using Barcode Professional for ASP.NET while displaying it at 96 DPI on an HTML page by writing some JavaScript code.
NOTE: In this guide we used Visual Studio 2005 (Visual Web Developer) but any VS .NET version can be used as well.
Follow these steps:
Dim dpi As Single = 96.0
Try
dpi = Single.Parse(context.Request.QueryString("dpi"))
Catch
End Try
Dim valueToEncode As String = context.Request.QueryString("valueToEncode")
Dim bcp As New Neodynamic.WebControls.BarcodeProfessional.BarcodeProfessional()
bcp.Symbology = Neodynamic.WebControls.BarcodeProfessional.Symbology.Code128
bcp.Code = valueToEncode
bcp.BarWidth = 0.01F
bcp.BarHeight = 0.5F
context.Response.ContentType = "image/jpeg"
context.Response.BinaryWrite(bcp.GetBarcodeImage(System.Drawing.Imaging.ImageFormat.Jpeg, dpi))
float dpi = 96.0f;
try
{
dpi = float.Parse(context.Request.QueryString["dpi"]);
}
catch
{ }
string valueToEncode = context.Request.QueryString["valueToEncode"];
Neodynamic.WebControls.BarcodeProfessional.BarcodeProfessional bcp = new Neodynamic.WebControls.BarcodeProfessional.BarcodeProfessional();
bcp.Symbology = Neodynamic.WebControls.BarcodeProfessional.Symbology.Code128;
bcp.Code = valueToEncode;
bcp.BarWidth = 0.01f;
bcp.BarHeight = 0.5f;
context.Response.ContentType = "image/jpeg";
context.Response.BinaryWrite(bcp.GetBarcodeImage(System.Drawing.Imaging.ImageFormat.Jpeg, dpi));
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>HTML Barcode image with DPI support</title> <script type="text/javascript"> var imageUrlGen = "BarcodeGen.ashx"; var imageID = "MyBarcodeImage"; var txtValueToEncodeID = "MyValueToEncode"; var tmpImage; var dpi = 600; function CheckForLoadedImage() { if(tmpImage.complete) { var img = document.getElementById(imageID); img.width = tmpImage.width * 96 / dpi; img.height = tmpImage.height * 96 / dpi; img.src = tmpImage.src; clearTimeout("CheckForLoadedImage()"); } else { setTimeout("CheckForLoadedImage()", 500); } } function GetBarcodeImage() { var valueToEncode = document.getElementById(txtValueToEncodeID).value; tmpImage = new Image(); tmpImage.src = imageUrlGen + "?valueToEncode=" + valueToEncode + "&dpi=" + dpi; CheckForLoadedImage(); } </script> </head> <body> <p> <b>Barcode Professional in a HTML page with DPI support</b> </p> <p> <img id="MyBarcodeImage" alt="" src="" /> </p> <p> Enter a value to encode:<br /> <input id="MyValueToEncode" type="text" name="MyValueToEncode" /> </p> <p> <input id="Button1" type="button" value="Get Barcode at 600 DPI..." name="Button1" onclick="GetBarcodeImage()" /> </p> </body> </html>
We provide best-in-class customer service and support directly from members of our dev team! If we are available when you contact us, you will get a response in few minutes; otherwise the maximum turnaround is 24hs in most cases.