我尝试像下面这样从 javascript 打印
function PrintElem() {
var mywindow = window.open('', 'PRINT');
mywindow.document.write('<html><head><title>Payment Slip</title>');
mywindow.document.write('</head><body style="text-align:center;font: Georgia, "Times New Roman", Times, serif;background: #fff;font-size: 22pt;margin:20px auto auto 50px;" >');
mywindow.document.write('<header style="text-align:center; white-space:nowrap;overflow:hidden;line-height: 1em;">' +
'<p style="font-size:16pt;white-space:nowrap;overflow:hidden;line-height: 12pt;">Payment Slip</p>' +
'<p style="font-size:16pt;white-space:nowrap;overflow:hidden;line-height: 1em;">' + $('.mylabelpaymentheader').html() + '</p>' +
'</header>');
mywindow.document.write('<content style="text-align:center;">' +
'<table style="margin-left: auto;margin-right: auto;border-collapse: collapse;font-size:16pt;">' +
'<tr style="border:1px solid black"><td style="border:1px solid black">Name:</td><td style="border:1px solid black">' + $('.lblName').html() + '</td></tr>' +
'<tr style="border:1px solid black"><td style="border:1px solid black">Address:</td><td style="border:1px solid black">' + $('.lblAddress').html() + '</td></tr>' +
'<tr style="border:1px solid black"><td style="border:1px solid black">Meter No:</td><td style="border:1px solid black">' + $('.lblMeterNo').html() + '</td></tr>' +
'<tr style="border:1px solid black"><td style="border:1px solid black">Token:</td><td style="border:1px solid black">' + $('.lblToken').html() + '</td></tr>' +
'</table>'+
'</content>' +
'<footer>' +
'<hr style="margin-top:30pt;margin-bottom:30pt;">' +
'<p style="text-align:right;">© pdb</p>' +
'</footer>'+
'');
mywindow.document.write('</body></html>');
mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10*/
mywindow.print();
mywindow.close();
return true;
}
打印时,字体太小。如果我增加字体大小,它不会反射(reflect)在 POS 打印机上。我使用 RP58 58mm 热敏收据打印机。我必须采用另一种方法吗?或者如何正确地做到这一点?
最佳答案
这是驱动程序问题。我使用适当的 58mm 选项再次设置驱动程序,一切都非常顺利。
关于javascript - 如何从 javascript(网络应用程序)打印到收据打印机?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42062230/