- KopSoftTool 条形码二维码标签编辑打印软件,C#串口通信SerialPort
- 官网
- github源码
- gitee源码
ZXing.Net条形码二维码打印软件
C#打印 1.建立PrintDocument对象2.设置PrintPage打印事件3.调用Print方法进行打印
Microsoft .NET Framework 4.5
ZXing.Net
BarcodeWriter用于生成图片格式的条码类,通过Write函数进行输出
BarcodeFormat枚举类型,条形码/二维码QrCodeEncodingOptions二维码设置选项,继承于EncodingOptions,主要设置宽,高,编码方式等MultiFormatWriter复合格式条码写码器,通过encode方法得到BitMatrixBitMatrix表示按位表示的二维矩阵数组,元素的值用true和false表示二进制中的1和0
using System;using System.Collections.Generic;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using ZXing;using ZXing.QrCode;namespace KopSoftPrint{ internal class QRCode { public void GenerateQRCode(string contents, PictureBox qrimage) { BarcodeWriter barcodeWriter = new BarcodeWriter { Format = BarcodeFormat.QR_CODE, Options = new QrCodeEncodingOptions { DisableECI = true, CharacterSet = "UTF-8", Width = qrimage.Width, Height = qrimage.Height, Margin = 1 //二维码边距 } }; Bitmap bitmap = barcodeWriter.Write(contents); qrimage.Image = bitmap; } }}
public void Print(int Number) { pd.DefaultPageSettings.PaperSize = new PaperSize("", 999, 999); //设置纸张大小 StandardPrintController controler = new StandardPrintController(); if (dataGridView1.CurrentCell != null) { for (int j = 0; j < dataGridView1.SelectedRows.Count; j++) //遍历所有选中的行 { rowIndex = dataGridView1.SelectedRows[j].Index; try { pd.PrintPage += new PrintPageEventHandler(pd_PrintPage); pd.PrintController = controler; for (int i = 0; i < Number; i++) { pd.Print(); } } catch (Exception e) { Console.WriteLine(e.Message); return; } finally { pd.Dispose(); } } } }
加强版地址