• 使用DotNetBarcode制作基本常用条码


    核心代码:
    ///
    <summary> /// 打印一维码 /// </summary> /// <param name="codeText"></param> /// <param name="g"></param> /// <param name="pointX"></param> /// <param name="pointY"></param> /// <param name="width"></param> /// <param name="height"></param> public void PrintBarcode(string codeText, Graphics g, int pointX, int pointY, int width, int height) { C1BarCode code = new C1BarCode(); code.CodeType = CodeTypeEnum.Code128; code.Text = codeText; try { g.DrawImage(code.Image, pointX, pointY, width, height); } catch (Exception ex) { if (code.Image == null) { MessageBox.Show("需要打印的字段中存在空值,条码会出现残缺,请检查是否维护了某些需要打印的字段" + ex.Message + " Some Information Need To Be Printed Is null, Please Contact Maintain It"); } } } /// <summary> /// 图片压缩式生成二维码,***添 /// </summary> /// <param name="e">e</param> /// <param name="QrBarcodeInfo">条码扫描出的信息</param> /// <param name="mapSize_x">bitmap x坐标</param> /// <param name="mapSize_y">bitmap y坐标</param> /// <param name="Qrbarcode_x">条码 x坐标</param> /// <param name="Qrbarcode_y">条码 y坐标</param> /// <param name="Qrbarcode_size">条码 长宽</param> public void Print_Image_Qrcode(System.Drawing.Printing.PrintPageEventArgs e, string QrBarcodeInfo, int mapSize_x, int mapSize_y, int Qrbarcode_x, int Qrbarcode_y, int Qrbarcode_size) { DotNetBarcode qrCode = new DotNetBarcode(DotNetBarcode.Types.QRCode); qrCode.QRQuitZone = 0; //qrCode.PrintChar = true; Bitmap bitmap = new Bitmap(mapSize_x, mapSize_y); //50 * 4, 50 * 4 Graphics gp = Graphics.FromImage(bitmap); //取图片作为 Graphics qrCode.QRWriteBar(QrBarcodeInfo, 0, 0, 2, gp); //画出二维码,图片的大小为二维码大小 gp.Dispose(); //pictureBox1.Image = bitmap; e.Graphics.DrawImage(bitmap, Qrbarcode_x, Qrbarcode_y, Qrbarcode_size, Qrbarcode_size); //将二维码图片 打印出来,缩放 35*4, 35*4 } /// <summary> /// 打印二维码 /// </summary> /// <param name="codeText"></param> /// <param name="pointX"></param> /// <param name="pointY"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="g"></param> public void PrintBarcode_QrCode(string codeText, float pointX, float pointY, float width, float height, Graphics g) { DotNetBarcode qrCode = new DotNetBarcode(DotNetBarcode.Types.QRCode); qrCode.QRQuitZone = 0; qrCode.WriteBar(codeText, pointX, pointY, width, height, g); }

    分享共进步,谢谢阅读!

  • 相关阅读:
    shell 编程 如何实现 比较两个整数的大小
    从Mysql某一表中随机读取n条数据的SQL查询语句
    AS3中UTF8、GB2312、BIG5、GBK编码转换类
    Google Map API V3 离线版
    linux下解压命令大全
    PHP 5.3无法安装Memcached解决方案
    根据淘宝商品 num_iid 批量生成淘宝客链接的 PHP 函数
    Linux curl使用简单介绍
    TCP/IP UDP用户数据报协议 运输层
    TCP/IP 应用层
  • 原文地址:https://www.cnblogs.com/imyao/p/5619339.html
Copyright © 2020-2023  润新知