Epson TM-U220 ePOS-Print XML Users Manual - Page 53
Reception of Print Result
View all Epson TM-U220 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 53 highlights
Chapter 3 Programming Guide Reception of Print Result Set a callback function using the response root element (p. 68) to receive print results. The following information is obtained: ❏ Print result ❏ Error code ❏ Printer status ❏ Printer's battery status The printer status can be obtained when communication with the printer is possible. Refer to the following program. For the details about how to program a callback function in detail, refer to Error handling (p.55). TITLE function sendDocument() { //Create a print document var request = ''; request += ''; request += ''; request += 'Hello, World! '; request += ''; request += ''; //Create a SOAP envelop var soap = '
53
Chapter 3
Programming Guide
Reception of Print Result
Set a callback function using the response root element (
p. 68
) to receive print results.
The following information is obtained:
❏
Print result
❏
Error code
❏
Printer status
❏
Printer's battery status
Refer to the following program. For the details about how to program a callback function in detail, refer to
Error
handling (p.55)
.
The printer status can be obtained when communication with the printer is possible.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>TITLE</title>
<script type="text/javascript">
function sendDocument() {
//Create a print document
var request = '<epos-print xmlns="http://www.epson-pos.com/schemas/2011/03/epos-
print">';
request += '<text lang="en" smooth="true"/>';
request += '<text font="font_a"/>';
request += '<text width="3" height="3">Hello, World! </text>';
request += '<cut type="feed"/>';
request += '</epos-print>';
//Create a SOAP envelop
var soap = '<?xml version="1.0" encoding="utf-8"?>' +
'<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>' + request + '</s:Body></s:Envelope>';
//Create an XMLHttpRequest object
var xhr = new XMLHttpRequest();
//Set the end point address
=local_printer&timeout=10000';
//Open an XMLHttpRequest object
xhr.open('POST', url, true);
//<Header settings>
xhr.setRequestHeader('Content-Type', 'text/xml; charset=utf-8');
xhr.setRequestHeader('If-Modified-Since', 'Thu, 01 Jan 1970 00:00:00 GMT');
xhr.setRequestHeader('SOAPAction', '""');