日期:2014-05-17 浏览次数:21037 次
/// <summary>
/// 根据单据号创建条码
/// </summary>
/// <param name="BillsNo">单据号</param>
/// <returns></returns>
private static string CreateBarcode(string BillsNo)
{
using (BarcodeLib.Barcode b = new BarcodeLib.Barcode())
{
int W = 400;//图片的宽
int H = 100;//图片的高
b.Alignment = BarcodeLib.AlignmentPositions.LEFT;//图片居中
BarcodeLib.TYPE type = BarcodeLib.TYPE.Interleaved2of5;//设置条码格式
byte[] imgBytes = null;
try
{
if (type != BarcodeLib.TYPE.UNSPECIFIED)
{
b.IncludeLabel = false;//条码下面是否显示值
b.RotateFlipType = (RotateFlipType)Enum.Parse(typeof(RotateFlipType), "RotateNoneFlipNone", true);//设置条码的旋转方式
b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMCENTER;//设置把条码搁置那个位置
Image img = b.Encode(type, BillsNo, Color.Black, Color.White, W, H);//生成图片
imgBytes = imageToByteArray(img);
}
return Convert.ToBase64String(imgBytes);
}
&nb