如何在Asp.Net中使用条形码 [英] How to use Bar-coding in Asp.Net
本文介绍了如何在Asp.Net中使用条形码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在Asp.Net项目中使用条形码。它有可能与否?如果可能,Plz发送编码,任何人都可以帮助我
Hi,
I want to use Bar-coding inside Asp.Net project. It''s possible or not? If possible Plz send the coding for that Any one can help me
推荐答案
是的,你可以。
查看以下链接:
FONT Embedding& ASP.NET中的条形码处理 [ ^ ]
ASP.NET应用程序中的条形码 [ ^ ]
ASP.NET条码生成器控件SDK教程 [ ^ ]
如何在ASP.NET中生成条形码 [ ^ ]
另请检查在asp.net中读取条形码 [ ^ ]
- Amit
Yes, you can.
Check these link:
FONT Embedding & Barcode Handling in ASP.NET[^]
Barcodes in ASP.NET applications[^]
ASP.NET Barcode Generator Control SDK Tutorial[^]
How to Generate Barcodes in ASP.NET[^]
Also check Reading barcode in asp.net[^]
--Amit
首先,你必须下载一个免费的条形码字体。在本例中,我使用了IdAutomation中的IDAutomationHC39M。在这个例子中,我使用了条形码39.
然后这是代码:
First, you have to download a free barcode font. For this example, I used "IDAutomationHC39M" from IdAutomation. In this example, I used Barcode 39.
Then this is the code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Barcodes
{
/// <summary />
/// Summary description for BarCode.
/// br mode="hold" />
public class BarCode : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Get the Requested code to be created.
string Code = Request["code"].ToString();
// Multiply the lenght of the code by 40 (just to have enough width)
int w = Code.Length * 40;
// Create a bitmap object of the width that we calculated and height of 100
Bitmap oBitmap = new Bitmap(w,100);
// then create a Graphic object for the bitmap we just created.
Graphics oGraphics = Graphics.FromImage(oBitmap);
// Now create a Font object for the Barcode Font
// (in this case the IDAutomationHC39M) of 18 point size
Font oFont = new Font("IDAutomationHC39M", 18);
// Let's create the Point and Brushes for the barcode
PointF oPoint = new PointF(2f, 2f);
SolidBrush oBrushWrite = new SolidBrush(Color.Black);
SolidBrush oBrush = new SolidBrush(Color.White);
// Now lets create the actual barcode image
// with a rectangle filled with white color
oGraphics.FillRectangle(oBrush, 0, 0, w, 100);
// We have to put prefix and sufix of an asterisk (*),
// in order to be a valid barcode
oGraphics.DrawString("*" + Code + "*", oFont, oBrushWrite, oPoint);
// Then we send the Graphics with the actual barcode
Response.ContentType = "image/jpeg" ;
oBitmap.Save (Response.OutputStream, ImageFormat.Jpeg);
}
}
}
这篇关于如何在Asp.Net中使用条形码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文