C#通过第三方组件生成二维码(QR Code)和条形码(Bar Code)

2019-12-30 15:00:58于海丽

1.3):附加具体生成条形码方法如下


private void GenerateBarCodeBySpire()
{
BarcodeSettings bs = new BarcodeSettings()
{
Data = "This is barcode: H2AMK-Z3V69-RTJZD-C7JAU-WILL4",
ShowCheckSumChar = false,
TopTextColor = Color.Red,
ShowTopText = false,
ShowTextOnBottom = true
};
//Generate the barcode based on the this.barCodeControl1
BarCodeGenerator generator = new BarCodeGenerator(bs);
Image barcode = generator.GenerateImage();
//save the barcode as an image
barcode.Save(@"E:barcode.png");
}

1.3):上诉代码我们发现生成的条形码和二维码带有水印[E-ICEBLUE],如何去除水印呢?请看如下代码

BarcodeSettings.ApplyKey("......");

请发送邮件到 sales@e-iceblue.com 免费获取对应的 key 值

更多详细信息请参考如下链接:

http://www.easck.com/

http://www.easck.com/Knowledgebase/Spire.BarCode/Program-Guide/Programme-Guide-for-Spire.BarCode.html

4):通过Barcode Rendering Framework(Zen.Barcode.Rendering.Framework.dll)来实现

4.1):首先通过VS2015的NuGet下载对应的第三方组件,如下图所示:

C#,qrcode二维码生成组件,qrchart组件

4.2):具体生成二维码方法如下


private void GenerateBarCodeByZen()
{
Code128BarcodeDraw barcode128 = BarcodeDrawFactory.Code128WithChecksum;
Image img = barcode128.Draw("Hello World", 40);
img.Save("E:/zenbarcode.gif");
}

4.3):附加具体生成条形码方法如下


private void GenerateQRByZen()
{
CodeQrBarcodeDraw qrcode = BarcodeDrawFactory.CodeQr;
Image img = qrcode.Draw("Hello World!", qrcode.GetDefaultMetrics(40));
img.Save("E:/zenqrcode.gif");
}

更多详细信息请参考如下链接:

http://www.easck.com/

5):通过BarcodeLib(BarcodeLib.Barcode.ASP.NET.dll)来实现,下载对应dll的连接为 http://www.easck.com/asp_net/

5.1):具体生成二维码方法如下


private void GenerateQRByBarcodeLib()
{
QRCode qrbarcode = new QRCode();
qrbarcode.Encoding = QRCodeEncoding.Auto;
qrbarcode.Data = "336699885522 This is Eric Sun Testing.";
qrbarcode.ModuleSize = 10;
qrbarcode.LeftMargin = 8;
qrbarcode.RightMargin = 8;
qrbarcode.TopMargin = 8;
qrbarcode.BottomMargin = 8;
qrbarcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Gif;
// Save QR Code barcode image into your system
qrbarcode.drawBarcode("E:/csharp-qrcode-lib.gif");
}

5.2):附加具体生成条形码方法如下


private void GenerateLinearByBarcodeLib()
{
Linear barcode = new Linear();
barcode.Type = BarcodeType.CODE128;
barcode.Data = "CODE128";
// other barcode settings.
// save barcode image into your system
barcode.drawBarcode("E:/barcode.png");
}