Created
June 27, 2020 12:51
-
-
Save hiepxanh/25578459423f5ac40d2a3e6ef8ea2e8f to your computer and use it in GitHub Desktop.
receipt cho bill.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<epos-print xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print"> | |
<text>Hello world </text> | |
<text>Hello </text> | |
<text>Hello </text> | |
<text>Hello </text> | |
<feed line="3"/> | |
<feed line="3"/> | |
<cut type="feed"/> | |
</epos-print> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var canvas = document.getElementById('canvas'); | |
var printer = null; | |
var ePosDev = new epson.ePOSDevice(); | |
ePosDev.connect('192.168.26.111', 8008, cbConnect); | |
function cbConnect(data) { | |
if(data == 'OK' || data == 'SSL_CONNECT_OK') { | |
ePosDev.createDevice('local_printer', ePosDev.DEVICE_TYPE_PRINTER, | |
{'crypto':false, 'buffer':false}, cbCreateDevice_printer); | |
} else { | |
alert(data); | |
} | |
} | |
function cbCreateDevice_printer(devobj, retcode) { | |
if( retcode == 'OK' ) { | |
printer = devobj; | |
printer.timeout = 60000; | |
printer.onreceive = function (res) { alert(res.success); }; | |
printer.oncoveropen = function () { alert('coveropen'); }; | |
print(); | |
} else { | |
alert(retcode); | |
} | |
} | |
function print() { | |
printer.addText('Hello world \n'); | |
printer.addText('Hello\n'); | |
printer.addText('Hello\n'); | |
printer.addText('Hello\n'); | |
printer.addFeedLine(3); | |
printer.addFeedLine(3); | |
printer.addCut(printer.CUT_FEED); | |
printer.send(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment