国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

分享一個C#創(chuàng)建Barcode的DLL

2019-11-17 02:48:08
字體:
供稿:網(wǎng)友

分享一個C#創(chuàng)建Barcode的DLL

用于工作需要產(chǎn)生Barcode,隨手從網(wǎng)上找了一個DLL(原文地址忘了)

http://files.VEVb.com/panchunting/barcode_bin.zip

使用非常簡單,只需添加引用,然后編碼如下

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());            }        }    }}

調(diào)用后臺頁面

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;        }    }}

調(diào)用前臺代碼

    <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>            <img id="imgBarcode" runat="server" style="height: 20mm; width: 100mm;" />        </li>    </ol>

最終效果如下

多說一句,img的長度要設(shè)長一點,尤其當(dāng)字符比較長的時候,否則可能掃描槍無法掃出


上一篇:開源組件整理

下一篇:C#生成二維碼

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 聂荣县| 新绛县| 满城县| 弋阳县| 六枝特区| 公安县| 名山县| 台山市| 睢宁县| 东阿县| 永寿县| 河西区| 鹰潭市| 吴川市| 勐海县| 增城市| 长武县| 常宁市| 沧州市| 中宁县| 余干县| 平遥县| 耒阳市| 宣威市| 麻江县| 天水市| 青神县| 喀喇沁旗| 景谷| 水富县| 无棣县| 苗栗市| 元阳县| 西贡区| 石门县| 象山县| 正定县| 滁州市| 崇明县| 清水河县| 区。|