How to display barcode images on HTML pages with DPI support with Barcode Professional for ASP.NET
Technologies used
- 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:
- Create an ASP.NET Web Site project using Visual Studio 2005
- Delete any ASPX file created in the project
- Create a BIN folder if needed and add a reference to the Barcode Professional for ASP.NET assembly (Neodynamic.WebControls.BarcodeProfessional.dll)
- Add a new item of type Generic Handler (a file which extension is ASHX) and name it BarcodeGen.ashx
- After that, write the following code in the ProcessRequest method in the BarcodeGen.ashx file. In this method will expect to receive (through the Query String) the value to be encoded in Code 128 Symbology and the image resolution (DPI) for generating the output barcode image by using an instance of Barcode Professional.
Visual Basic .NET
Visual C# .NET
- Then, add a new item to the project of type HTML Page. This simple HTML will display the barcode image generated (at 600 DPI) by the previous HTTP handler at 96 DPI on the client's browser by using JavaScript code. Write the following HTML code:
- That's it. Test the HTML page and see what happens. Keep in mind that although the image is resized by using JavaScript code, the generated image's quality is maintained with great printing results.
If you need more information or assistance, please contact our
.
|