qrcode生成二維碼,並使用LODOP批量打印


生成二維碼需要引用qrcode.js

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

js代碼--生成二維碼,:

1    var qrcode = new QRCode(document.getElementById("qrcode"), {
2                     width: 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                     width: 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=\"width:100%;text-align:left;font-family:'宋體';font-weight: bold\">";
29                 table += "<tr><td style=\"text-align:center;font-size:12pt;\"><img src='" + strDataURI + "' style='width: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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM