Reputation: 2337
I have an ASP.NET MVC application where I am generating around 20 QR codes on a button click. I want to print these QR codes using label printer (20 QR codes into 20 labels so that they can be pasted).
The QR code format is:
Image (on 1st line)
Text (on 2nd line)
Currently I am using the below code to open a dialog with qr codes and it prints on a A4 paper but not as labels.
$("#test2").html("");
var divID = 0;
$.ajax({
type: "POST",
url: '/PrintQRCode/print',
data: null,
dataType: "JSON",
success: function (d) {
if (d != "") {
var tr = "<tr>";
$("#test2").append("<tbody><tr></tr></tbody>");
$(d.data).each(function (index, row) {
tr += "<td><div id=" + divID + "></div><div style='font-size:14px;'><label>" + row.AssetNumber + "</label></div></td>";
GenerateQRCode(divID);
}
divID = divID + 1;
});
tr += "</tr>";
$("#test2 tbody").append(tr);
var divContents = document.getElementById("test2").innerHTML;
var printWindow = window.open('', '', 'height=600,width=1000');
printWindow.document.write('<html><head><title>Print Asset Barcodes</title>');
printWindow.document.write('</head><body>');
printWindow.document.write(divContents);
printWindow.document.write('</body></html>');
printWindow.document.close();
printWindow.print();
}
},
error: function () {
alert("Some errors have occurred. Please try again later");
}
});
});
On searching, I have found ways to print barcodes using ZPL via Winforms but not via web applications also not specific to QR codes.
Am I missing something or it is the same code of barcodes used for QR codes?
Upvotes: 0
Views: 212