封装条形码MaHelper
using Spire.Barcode; using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Web; namespace WebApplication2 { public class MaHelper { public string T1(string data,string ss) { //创建BarcodeSettings对象 BarcodeSettings settings = new BarcodeSettings(); //设置条形码类型为EAN - 13 settings.Type = BarCodeType.EAN13; //设置条形码数据 //string tt = "111111789012"; settings.Data = data; //使用校检和 settings.UseChecksum = CheckSumMode.ForceEnable; //在底部显示条形码数据 settings.ShowTextOnBottom = true; //在底部显示条形码数据 settings.X = 1f; //初始化BarCodeGenerator对象, 传入以上设置 BarCodeGenerator generator = new BarCodeGenerator(settings); //创建条形码图片并保存为PNG格式 Image image = generator.GenerateImage(); //物理路径 //string ss = Server.MapPath("~/AAA/"); string path = ss + data + ".png"; image.Save(path, System.Drawing.Imaging.ImageFormat.Png); //ViewBag.ww = "~/AAA/" + data + ".png"; //string s = "<img src='/AAA/" + data + ".png' alt='' />"; string lu = "/AAA/" + data + ".png"; return lu; } public string T2(string data, string ss) { //创建 BarcodeSettings 对象 BarcodeSettings settings = new BarcodeSettings(); //设M条码类型为二维码 settings.Type = BarCodeType.QRCode; //设M二维码数据 //string tt1 = "111111119"; settings.Data = data; //设M数据类型为数字 settings.QRCodeDataMode = QRCodeDataMode.Numeric; //不显示文本 settings.ShowText = false; //设M二维码错误修正级别 settings.QRCodeECL = QRCodeECL.H; //设M宽度 settings.X = 2.0f; //初始化 8arCodeGenerator 对象 BarCodeGenerator generator = new BarCodeGenerator(settings); //创建二维码图片并保存为PNG格式 Image image1 = generator.GenerateImage(); //物理路径 //string ss1 = Server.MapPath("~/AAA/"); string path1 = ss + data + "1.png"; image1.Save(path1); // ViewBag.ww1 = "~/AAA/" + data + ".png"; //string s = "<img src='/AAA/" + data + ".png' alt='' />"; string lu = "/AAA/" + data + "1.png"; return lu; } } }