admin管理员组文章数量:1431702
I tried to print from javascript like below
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;
}
when print out.font was too small.if I increase font size, it does not reflect on POS printer.I used RP58 58mm Thermal Receipt Printer. Do i have to follow another approach? or how to do it correctly?
I tried to print from javascript like below
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;
}
when print out.font was too small.if I increase font size, it does not reflect on POS printer.I used RP58 58mm Thermal Receipt Printer. Do i have to follow another approach? or how to do it correctly?
Share Improve this question asked Feb 6, 2017 at 7:17 decoderdecoder 9261 gold badge23 silver badges49 bronze badges 2- I need to know the answer of this question, I wonder did you manage to figure out? – Coder Absolute Commented Feb 9, 2017 at 3:59
- 1 Have y'all seen this project: github./mike42/escpos-php – Blundering Philosopher Commented Mar 7, 2017 at 22:34
1 Answer
Reset to default 3It was driver issue.I set up driver again with appropriate 58mm option and everythings works like a charm.
本文标签: aspnetHow to print from javascript (web app) to receipt printerStack Overflow
版权声明:本文标题:asp.net - How to print from javascript (web app) to receipt printer? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745591790a2665244.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论