Printing After Checking the Printer Status
To ensure successful print operation, print after checking the printer status.
Send the empty print data, and if the printer is online, print it.
Use the programming example below for your reference.
//<Send data for confirmation>
Print printer = new Print();
int[] status = new int[1];
status[0] = 0;
try {
//Create a print document
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addText("Hello, World!\n");
builder.addCut(Builder.CUT_FEED);
//Initialize a Builder class instance for confirmation
Builder conBuilder = new Builder("TM-T88V", Builder.MODEL_ANK);
//<Start communication with the printer>
printer.openPrinter(Print.DEVTYPE_TCP, "192.168.192.168");
//<Send data for confirmation>
printer.sendData(conBuilder, 10000, status);
if((status[0] & Print.ST_OFF_LINE) != Print.ST_OFF_LINE){
//<Send print data>
printer.sendData(builder, 10000, status);
}
//<End communication with the printer>
printer.closePrinter();
} catch (EposException e) {
int errStatus = e.getErrorStatus();
status[0] = e.getPrinterStatus();
printer.closePrinter();
}
1
Create print data.
2
To check the printer status, send empty print data.
3
Send the print data created in [2].
4
If the print data created in [2] was properly sent, and the printer is online, then
send the print data created in [1].
Chapter 3 Programming Guide
[1]
[2]
[3]
[4]
3
33