C# 生成条形码
上一篇分享了关于二维码的生成,本篇将分享条形码。
该方法需要引用 BarcodeLib.dll
链接: https://pan.baidu.com/s/1GhEG9-UDa3-2-bSoT62zkA
提取码: h72q
1public static Image CreateBarCode(string content) 2 { 3 using (var barcode = new Barcode() 4 { 5 //true显示content,false反之 6 IncludeLabel = true, 7 8 //content的位置 9 Alignment = AlignmentPositions.CENTER, 10 11 //条形码的宽高 12 Width = 150, 13 Height = 50, 14 15 //类型 16 RotateFlipType = RotateFlipType.RotateNoneFlipNone, 17 18 //颜色 19 BackColor = Color.White, 20 ForeColor = Color.Black, 21 }) 22 { 23 return barcode.Encode(TYPE.CODE128B, content); 24 } 25 }