Reputation: 23
I have a MVC web application where we want to print the receipt, but since we have POS system and a thermal printer attached, we do not want the print dialogue box and the receipt should be directly printed.
We have the following code but are getting the pop up. Can anyone kindly help in this matter? We are looking for full cross-browser support.
The code is attached below:
<script type="text/javascript">
// var q = jQuery.noConflict();
$("#btnPrint").live("click", function () {
var divContents = $("#dvContainer").html();
var printWindow = window.open('', '', 'height=400,width=800');
printWindow.document.write('<html><head><title>DIV Contents</title>');
printWindow.document.write('</head><body >');
printWindow.document.write(divContents);
printWindow.document.write('</body></html>');
printWindow.document.close();
printWindow.print();
q('.print default').trigger('click');
});
</script>
Thanks in advance.
Upvotes: 1
Views: 8171
Reputation: 23231
The only sure-fire way to do this across all browsers is to run a special daemon in the background that you call AJAX requests to that does the print requests. Here is one such product.
Upvotes: 0
Reputation: 2104
You have 2 options here.
Option one,
To send raw data to a printer from the Microsoft .NET Framework, your program must work with Win32 spooler functions. However, with the .NET Framework, you cannot send preformatted printer-ready data to a printer.
Read more here.
Option two,
WebClientPrint for ASP.NET. here is more info on this. Link
Upvotes: 1