Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <title>Print Test</title>
- <script type="text/javascript" src="epos-2.3.0.js"></script>
- <script type="text/javascript">
- var ePosDev = new epson.ePOSDevice();
- function connect()
- {
- var ipAddress = '192.168.1.23';
- var port = '9100';
- ePosDev.connect(ipAddress, port, callback_connect);
- }
- function callback_connect(resultConnect)
- {
- alert('Callback Called');
- var deviceId = 'local_printer';
- var options = {'crypto' : false, 'buffer' : false};
- alert(resultConnect);
- if ((resultConnect == 'OK') || (resultConnect == 'SSL_CONNECT_OK')) {
- alert('Connected!');
- ePosDev.createDevice(deviceID,ePosDev.DEVICE_TYPE_PRINTER,options,callback_createDevice);
- }
- else
- {
- alert('Not Connected!');
- }
- }
- var printer = null;
- function callback_createDevice(deviceObj, errorCode)
- {
- if (deviceObj === null)
- {
- //Displays an error message if the system fails to retrieve the Printer object
- return;
- }
- printer = deviceObj;
- //Registers the print complete event
- printer.onreceive = function(response)
- {
- if (response.success)
- {
- //Displays the successful print message
- }
- else
- {
- //Displays error messages
- }
- };
- }
- function createData()
- {
- printer.addTextAlign(printer.ALIGN_CENTER);
- printer.addText("Hello World\n");
- }
- function send()
- {
- if (ePosDev.isConnected)
- {
- printer.send();
- }
- }
- </script>
- </head>
- <body>
- <input type="button" onclick="connect()" value="Connect" />
- <input type="button" onClick="send()" value="Print Hello World" />
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement