49
Chapter 3 Programming Guide
3
Reception of Print Result
The print result can be received by setting a callback function using the onreceive property (p. 148) of the
ePOS-Print object. The following information is obtained:
❏
Print result
❏
Error code
❏
Printer status
Refer to the following program. For the details about how to program a callback function in detail, refer to
.
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" src="epos-print-3.x.x.js"></script>
<script type="text/javascript">
function buildMessage() {
//Create a print document
var builder = new epson.ePOSBuilder();
builder.addTextLang('en');
builder.addTextSmooth(true);
builder.addTextFont(builder.FONT_A);
builder.addTextSize(3, 3);
builder.addText('Hello,\tWorld!\n');
builder.addCut(builder.CUT_FEED);
var request = builder.toString();
var address = 'http://192.168.192.168/cgi-bin/epos/
service.cgi?devid=local_printer&timeout=10000';
//Create an ePOS-Print object
var epos = new epson.ePOSPrint(address);
//Set a response receipt callback function
epos.onreceive = function (res) {
//When the printing is not successful, display a message
if (!res.success) {
alert('A print error occurred');
}
}
//Send the print document
epos.send(request);
}
</script>
</head>
<body>
<button onclick=”buildMessage()”>Run</button>
</body>
</html>
Print result receipt
callback function
Summary of Contents for TM-T88V-i
Page 10: ...10 ...
Page 14: ...14 ePOS Print Canvas API Monochrome or Grayscale Monochrome ...
Page 160: ...160 ...
Page 258: ...258 ...