Barcode Professional for ASP. NET use Tutorial: How to display high-definition barcodes within the DPI range of HTML support

Source: Internet
Author: User

We know that high-quality barcodes are better for our purposes, but the image dpi is proportional to the size of the image, the higher the DPI, the larger the picture file.

650) this.width=650; "alt=" barcode "class=" Img-thumbnail "src=" http://image.evget.com/images/article/2015/ Barcode.jpg "width=" 553 "height=" 358 "style=" width:553px;height:358px; "/>

It may be easy for you to display a 600DPI picture in HTML, but you'll find that the picture fills the entire page because most of the HTML display resolution is 96DPI. Then today will be shared with barcode Professional for ASP. NET displays high-definition barcodes within the DPI range of HTML support. The code is for informational purposes only.

Note: We are using Visual Studio 2005 (Visual Web Developer), but some vs.net are also available.

Steps :

    • Create an ASP. NET Web Project with Visual Studio 2005.

    • Delete all the ASPX files created in the project.

    • If there is a need to create a bin folder, add a reference to barcode Professional for ASP. NET collection.

    • Add a new project type naming barcodegen.ashx in generic Handler.

    • Enter the following code in the Barcodegen.ashx file using the ProcessRequest method, which will get the 128-yard symbol encoding value and the output barcode image resolution through a string query.

Vb

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.01fbcp.barheight = 0.5fcontext.response.contenttype = "Image/jpeg" context. Response.BinaryWrite (bcp. Getbarcodeimage (System.Drawing.Imaging.ImageFormat.Jpeg, DPI))

C#

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));
    • Then add the new item to the HTML page item, this HTML page will display the 600DPI barcode image, this is by using the JS code in other browsers to display the 96DPI HTTP processing. The following code is lost:

<! doctype html public  "-//w3c//dtd xhtml 1.0 transitional//en"   "HTTP// Www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> 

Completed, although the image size is generated by the JS code, but the quality of the generated image is consistent with the printing results.

Barcode Professional for Asp.net>>

This article is from the "294936239" blog, please be sure to keep this source http://294936239.blog.51cto.com/10806039/1711088

Barcode Professional for ASP. NET use Tutorial: How to display high-definition barcodes within the DPI range of HTML support

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.