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

  • 相关阅读:
    区块链技术赋能证券业 多家券商业务率先“上链”
    分布式金融的基础设施:如何驱动主流采用?
    回顾|2019年中国金融科技行业研究报告
    智能投顾行业深度报告:技术为镐,蓝海掘金
    毕马威举办2019中国领先金融科技企业50颁奖典礼
    智能投顾监管半年考:牌照合规 接受度仍待考验
    PostgreSQL串行化隔离级别(SSI)的能力与实现
    邹传伟:对人民银行DC/EP的初步分析
    央行辟谣未发行“DC/EP”和“DCEP” 法定数字货币仍在测试阶段
    php进程daemon化的正确做法
  • 原文地址:https://www.cnblogs.com/Leeblog200814/p/13577794.html
Copyright © 2011-2022 走看看