Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Direct Print after clicking

I am using a JS function in my POS website which is:

<script type="text/javascript">
function printlayer(layer){
  var generator=window.open(",'name,");
  var layertext=document.getElementById(layer);
  generator.document.write(layertext.innerHTML.replace('Print Me'));
  generator.document.close();
  generator.print();
  generator.close();
}

When I click on Print button, it opens a new Print tab on screen but I want to print directly. Suppose I clicked on print, it should print directly. "IT SHOULD NOT OPEN THE PRINT TAB". I am using Thermal Receipt Printer: GPrinter Modal is: GP80160II Paper width: 80mm Print Speed: 160mm/sec.

This Picture is before clicking Print: enter image description here

This Picture is After clicking (That I don't want): enter image description here Please Help me. I am not able to do this. Thanks in advance

like image 986
Kami Avatar asked Jan 29 '26 23:01

Kami


1 Answers

If you are using IE browser then this can be achieved. But in firefox and chrome we can't bypass the dialogue box. You can avoid the print dialog from any application by using some cloud printing REST API.

Select a printer and silently print(SO)

https://developers.google.com/cloud-print/docs/appInterfaces

https://www.printnode.com/docs/api/curl/

like image 65
PALLAMOLLA SAI Avatar answered Feb 01 '26 13:02

PALLAMOLLA SAI



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!