Used for work need to produce barcode, from the Internet to find a DLL (the original address forgot)
Http://files.cnblogs.com/panchunting/barcode_bin.zip
The use is very simple, just add the reference and then encode the following
usingSystem;usingSystem.Collections.Generic;usingSystem.Drawing;usingSystem.Linq;usingsystem.web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingBarcodelib;namespacewebappbarcode{ Public Partial classGetBarCodeImage:System.Web.UI.Page {protected voidPage_Load (Objectsender, EventArgs e) { stringStrencode = request.querystring["Code"]; CreateImage (Strencode); } Private voidCreateImage (stringCode) {Barcodelib.barcode Barcode=NewBarcodelib.barcode () {IncludeLabel=true, Alignment=Alignmentpositions.center, Width= -, Height= -, RotateFlipType=Rotatefliptype.rotatenoneflipnone, BackColor=Color.White, ForeColor=Color.Black,}; System.Drawing.Image img=Barcode. Encode (TYPE. CODE128B, Code); using(System.IO.MemoryStream ms =NewSystem.IO.MemoryStream ()) {img. Save (MS, System.Drawing.Imaging.ImageFormat.Jpeg); Response.clearcontent (); Response.ContentType="Image/png"; Response.BinaryWrite (Ms. ToArray ()); } } }}
Invoke Background page
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;namespacewebappbarcode{ Public Partial class_default:page {protected voidPage_Load (Objectsender, EventArgs e) { } protected voidButton1_Click (Objectsender, EventArgs e) {IMGBARCODE.SRC="~/getbarcodeimage.aspx? Code="+ This. TextBox1.Text; } }}
Calling foreground code
<olclass= "Round"> <Li> <Asp:textboxID= "TextBox1"runat= "Server"></Asp:textbox> <Asp:buttonID= "Button1"runat= "Server"Text= "Barcode"OnClick= "Button1_Click" /> </Li> <Li> <imgID= "Imgbarcode"runat= "Server"style= "height:20mm; width:100mm;" /> </Li> </ol>
The final effect is as follows
To say more, the length of the IMG should be set a little longer, especially when the character is longer, otherwise the scanner can not sweep out
Share a C # DLL that creates barcode