winform 生成条形码

Nuget管理包添加 BarcodeLib

代码实现:

 /// <summary>
        /// 生成条形码
        /// </summary>
        /// <param name="width">条形码的宽度</param>
        /// <param name="height">条形码的高度</param>
        /// <param name="content">条形码内容</param>
        /// <returns></returns>
        public static Image GenerateBarCodeBitmap(int width,int height, string content)
        {
            using (var barcode = new Barcode()
            {
                IncludeLabel = true,
                Alignment = AlignmentPositions.CENTER,
                Width = width,
                Height = height,
                RotateFlipType = RotateFlipType.RotateNoneFlipNone,
                BackColor = Color.White,
                ForeColor = Color.Black,
            })
            {
                return barcode.Encode(TYPE.CODE128B, content);
            }
        }


上一篇:Django models 中导入重复数据的解决办法


下一篇:EFCore生产环境数据库升级方案