Java hot-Sensitive POS Printer Programming _ Programming

Source: Internet
Author: User
Tags ticket

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.