I'm trying to make a cash drawer kick open. The command that needs to be sent to the drawer, by way of the receipt printer, is "chr(27).chr(112).chr(0).chr(100).chr(250)". Is there a way to send this command through javascript or other web based language. I want the cash drawer to only open only during certain receipt prints.
-
2Well, how can you talk to the printer? Does it understand HTTP? Is it connected to something that can run Javascript? – deceze Jul 01 '10 at 03:47
1 Answers
For background first see my answer here How to print a receipt through Receipt Printer from Web Page(.aspx)?
The ESC/P cash draw code you have is correct as per: http://www.beaglehardware.com/howtoprogramcashdrawer.html
The problem is discussed here: https://code.google.com/p/jzebra/issues/detail?id=134
POS world says the kickout code is: 1B 70 00 40 F0, however the "00" won't work (it's a limitation of the web browser)
Download jZebra - it's now evolved into the qz-print library, put the jar file in the project directory and the first method in this jzebra mail thread works for me:
<form id="form1" runat="server">
<div>
<input type=button onClick="openCashDrawer()" value="Open Cash Drawer">
<applet name="jzebra" code="jzebra.PrintApplet.class" archive="./jar/jzebra.jar" width="100" height="100">
<param name="printer" value="zebra">
</applet>
<script>
function chr(i) {
return String.fromCharCode(i);
}
function openCashDrawer() {
document.jzebra.append(chr(27) + "\x70" + "\x30" + chr(25) + chr(25) + "\r");
document.jzebra.print();
}
</script>
The base64 and appendFile methods discussed in that thread didn't work for me but apparently appendFile(file with raw ESC/P Commands)
and append64(base64)
do workaround the "Chr(0)" limitation.

- 61,933
- 36
- 195
- 321
-
+1 for ans, I have very less knowledge about applet, my application is php javascript, do you know for this to work, where do i have to download the plugin. – Bhavin Rana Aug 18 '19 at 18:10
-
@BhavinRana I've updated this and my other answer with the new jZebra library, looks like its called **qz-print** these days. It will work as long as the end users follow the instructions to set up the receipt printer (naming it jZebra) and connect the RJ45 cord to the Cash Drawer and send the correct cash drawer opening code. – Jeremy Thompson Aug 19 '19 at 00:23