Share a C # create a Barcode DLL,

Source: Internet
Author: User

Share a C # create a Barcode DLL,

For work, Barcode is generated, and a DLL is retrieved from the Internet (the original address is forgotten)

Http://files.cnblogs.com/panchunting/barcode_bin.zip

It is very easy to use. You only need to add references and encode them as follows:

using System;using System.Collections.Generic;using System.Drawing;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using BarcodeLib;namespace WebAppBarcode{    public partial class GetBarCodeImage : System.Web.UI.Page    {        protected void Page_Load(object sender, EventArgs e)        {            string strEncode = Request.QueryString["Code"];            CreateImage(strEncode);        }        private void CreateImage(string Code)        {            BarcodeLib.Barcode barcode = new BarcodeLib.Barcode()            {                IncludeLabel = true,                Alignment = AlignmentPositions.CENTER,                Width = 300,                Height = 100,                RotateFlipType = RotateFlipType.RotateNoneFlipNone,                BackColor = Color.White,                ForeColor = Color.Black,            };            System.Drawing.Image img = barcode.Encode(TYPE.CODE128B, Code);            using (System.IO.MemoryStream ms = new System.IO.MemoryStream())            {                img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);                Response.ClearContent();                Response.ContentType = "image/png";                Response.BinaryWrite(ms.ToArray());            }        }    }}

Call the background page

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace WebAppBarcode{    public partial class _Default : Page    {        protected void Page_Load(object sender, EventArgs e)        {        }        protected void Button1_Click(object sender, EventArgs e)        {            imgBarcode.Src = "~/GetBarCodeImage.aspx?Code=" + this.TextBox1.Text;        }    }}

Call front-end code

    <ol class="round">        <li>            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>            <asp:Button ID="Button1" runat="server" Text="Barcode" OnClick="Button1_Click" />        </li>        <li>                    </li>    </ol>

The final result is as follows:

The img length should be a little longer, especially when the characters are long, otherwise the scanner may not be able to scan


Questions about a sharing website in C Language

You have to lose it yourself. Someone asked you before...

In C language, how can multiple functions share a variable?

Define global variables?
Not quite clear about your requirements,
Generally, at the beginning of the Code, the global variables are defined after the pre-compilation,
Or define a static variable, such:
Static int;

Related Article

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.