Today, there is time to tidy up on the Java control of thermal POS printers Some of the attention, or fear later will forget.
The so-called heat-sensitive POS printer, is small supermarket small ticket printer. For this printer, I also only half understand, such as the wrong place, please correct me.
The POS printer's instruction set seems to come from the Japanese standard. Because I use a few POS printers, are able to identify the Japanese standard instructions.
Look at the printer instruction set, I believe many people can not understand. But it's easy to understand, give the following example:
ESC c 4 N Select printer paper sensor to stop printing
[format] ASCII ESC c 4 n
hexadecimal code 1 B-N
decimal code- n
[Range] 0≤n≤255
The above instruction can be used to stop printing. How do you understand this command? ESC This instruction is expressed in hexadecimal code, then the instruction is 1B (or the C's Table method 0x what), the decimal representation is 27. Then in turn, n is a mutable variable, such as n in decimal, if the value is 0 to prohibit printing, and 1 to allow. The instructions for the specific n are shown below:
Do you understand me?
So here's how I write a Java paper-cutting instruction, in decimal notation:
/** Paper Cutting command
/public static byte[] Getcutpaperbyte () {
byte [] buffer = new BYTE[5];
Buffer[0]= ' \ n ';//command must be a single
buffer[1]=29;
buffer[2]=86;
buffer[3]=66;
Buffer[4]=1;
return buffer;
}
Here is a note: the instructions to the printer must be at the beginning of a line, otherwise it will not be recognized as an instruction. Instructions can be added to the end of the text to be printed, can be small ticket machine automatic cutting paper, is not very human. There are more interesting instructions, such as warning, no paper when prompted, and so on.
In addition, the Android phone, flat-panel control POS Printer's instructions are the same OH. Oh
More detailed already put in their own network disk