zoukankan      html  css  js  c++  java
  • qrcode生成二维码,并使用LODOP批量打印

    生成二维码需要引用qrcode.js

    1 <div id="qrcode" style="display:none;300px;height:300px;"></div>
    2 <script src="~/Scripts/qrcode.js"></script>

    js代码--生成二维码,:

    1    var qrcode = new QRCode(document.getElementById("qrcode"), {
    2                      300,
    3                     height: 300,
    4                     render: "canvas",
    5                     text: “显示内容”
    6                 });

    使用LODOP打印需要的代码:

     1 var LODOP = getLodop(); 
     2 //生成标签
     3         function PrintItemLabel() {
     4            
     5 
     6             //预览比例,工具栏,直接打印,宽度,高度
     7             LODOP.SET_PRINT_PAGESIZE(1, "70mm", "60mm", "");                //纸张类型(方向、宽、高、名称)
     8             LODOP.SET_PRINT_MODE("POS_BASEON_PAPER", true);                 //从纸张边开始计算
     9             LODOP.SET_SHOW_MODE("NP_NO_RESULT", true);                      //兼容谷歌浏览器
    10 
    11             LODOP.SET_PREVIEW_WINDOW(1, 0, 0, 700, 600, "标签打印");        //设置预览窗口(预览比例,工具栏,直接打印,宽度,高度)
    12 
    13             $.each(rows, function (n, row) {
    14                 LODOP.NEWPAGEA();
    15                 var qrcode = new QRCode(document.getElementById("qrcode"), {
    16                      300,
    17                     height: 300,
    18                     render: "canvas",
    19                     text: "二维码扫描显示内容'"
    20                 });
    21                 $("canvas").attr("id", "erw");
    22                 var canvas = document.getElementById('erw');
    23                 var context = canvas.getContext('2d');
    24                 var image = new Image();
    25                 var strDataURI = canvas.toDataURL("image/png");
    26                 $("#qrcode").empty();
    27 
    28                 var table = "<table class=\"header\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\" style=\"100%;text-align:left;font-family:'宋体';font-weight: bold\">";
    29                 table += "<tr><td style=\"text-align:center;font-size:12pt;\"><img src='" + strDataURI + "' style='110px;height:110px;'/></td>";
    30                 table += "<tr><td style=\"text-align:center;font-size:12pt;\">" + row.Name + "<table>";
    31 
    32                 LODOP.ADD_PRINT_HTM(30, 40, 180, 180, table);
    33 
    34             });
    35             LODOP.PREVIEW();
    36         }

    最终页面

    PS:

    使用LODOP也可直接生成二维码:

    LODOP.ADD_PRINT_BARCODE(Top,Left,Width,Height,BarCodeType,BarCodeValue);

    Width 条码的总宽度,计量单位px(1px=1/96英寸)
    Height 条码的总高度(一维条码时包括文字高度)
    BarCodeType
     条码的类型(规制)名称,共有26种
    BarCodeValue
     条码值

    相关内容可参见:http://www.lodop.net/demolist/PrintSample11.html

  • 相关阅读:
    python开源项目聚合推荐【1】
    python开发--Python实现延时操作的几种方式
    odoo开发笔记 -- 单台物理服务器上,利用docker部署多套odoo应用
    odoo开发笔记 -- odoo官方docker启动原理
    odoo开发笔记 -- odoo官方docker镜像部署
    odoo开发笔记 -- 借助模块queue_job实现异步方法调用
    odoo开发笔记 -- 提高访问安全性的一种方式
    python开发笔记-pymsslq连接操作SqlServer数据库
    运维笔记--Debian/Ubuntu系统离线安装pymssql,连接SqlServer
    python开发笔记-str转字典
  • 原文地址:https://www.cnblogs.com/Leeblog200814/p/13577794.html
Copyright © 2011-2022 走看看