b/s(asp.net):先添加引用BarcodeLib.dll,然后再后台写代码:
//生成条形码
BarcodeLib.TYPE type = BarcodeLib.TYPE.UNSPECIFIED;
type = BarcodeLib.TYPE.CODE93;
try
{
if (type != BarcodeLib.TYPE.UNSPECIFIED)
{
b.IncludeLabel = IsInclud;
b.Encode(type, number, System.Drawing.Color.Black, System.Drawing.Color.White, 200, 70).Save (Server.MapPath("../Photos/carCode.jpg"));
imgCarNum.ImageUrl = "~/Photos/carCode.jpg?id=" + rd.Next(1, 1000);
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
c/s(winform): 先添加引用BarcodeLib.dll,然后再后台写代码:
//生成条形码
BarcodeLib.Barcode b = new BarcodeLib.Barcode();
bool IsInclude = true;
private void CreateBarCode()
{
BarcodeLib.TYPE type = BarcodeLib.TYPE.UNSPECIFIED;
type = BarcodeLib.TYPE.CODE93;
try
{
if (type != BarcodeLib.TYPE.UNSPECIFIED)
{
b.IncludeLabel = IsInclude;
pictureBox1.Image = b.Encode(type, "W" + System.DateTime.Now.ToString("yyMMddHHmmss"), Color.Black, Color.White, 200, 100);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
//生成条形码
BarcodeLib.TYPE type = BarcodeLib.TYPE.UNSPECIFIED;
type = BarcodeLib.TYPE.CODE93;
try
{
if (type != BarcodeLib.TYPE.UNSPECIFIED)
{
b.IncludeLabel = IsInclud;
b.Encode(type, number, System.Drawing.Color.Black, System.Drawing.Color.White, 200, 70).Save (Server.MapPath("../Photos/carCode.jpg"));
imgCarNum.ImageUrl = "~/Photos/carCode.jpg?id=" + rd.Next(1, 1000);
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
c/s(winform): 先添加引用BarcodeLib.dll,然后再后台写代码:
//生成条形码
BarcodeLib.Barcode b = new BarcodeLib.Barcode();
bool IsInclude = true;
private void CreateBarCode()
{
BarcodeLib.TYPE type = BarcodeLib.TYPE.UNSPECIFIED;
type = BarcodeLib.TYPE.CODE93;
try
{
if (type != BarcodeLib.TYPE.UNSPECIFIED)
{
b.IncludeLabel = IsInclude;
pictureBox1.Image = b.Encode(type, "W" + System.DateTime.Now.ToString("yyMMddHHmmss"), Color.Black, Color.White, 200, 100);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}