开发者

Javascript: Is there a way to send a cash drawer kick code?

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(开发者_StackOverflow250)". 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜