ESC/POS command set (excerpt)
Paper Cutting command:
Sending: hexadecimal: 1b69
4.1 basic control commands
4.1.1 ESC @
[Name] initialize the printer
[Format] ASCII code ESC @
Hexadecimal code 1B 40
Decimal code 27 64
[Description] clears the data in the print buffer and resets the printer print parameters to the default printer parameters.
[Note] * the USER parameter settings are not completely restored to the factory settings (see Figure 3. jpm112 printer tool software.
[Example] char sendstr [3];
Sendstr [0] = 0x1b
Sendstr [1] = 0 × 40;
Prtsenddata (sendstr, 2 );
4.1.2 FF
[Name] print and go to the top
[Format] ASCII code FF
14/53
-------- 16 --------
User Manual jpm112 printer development manual (V1.0)
Hexadecimal code 0c
Decimal 12
[Description] print all the data in the print buffer and return to the standard mode.
[Note] * after printing, delete the data in the print buffer.
* This command sets the printing position as the starting point of the line.
* If the printed paper has a pre-printed black mark, print the data in the buffer zone and go to the black mark. If the printed paper has no black mark
The pre-printed black mark will be stopped after MB of paper. For the pre-printed black mark specification, see Appendix B. pre-printed black mark description.
[Example] char sendstr [2];
Sendstr [0] = 0x0c;
Prtsenddata (sendstr, 1 );
4.1.3 lf
[Name] print and wrap
[Format] ASCII code lf
Hexadecimal code 0a
Decimal code 10
[Description] print the data in the print buffer and wrap the line.
[Note] * This command sets the printing position to the starting position of the line.
[Reference] cr
[Example] char sendstr [2];
Sendstr [0] = 'n'; // in C, 'n' is a line feed.
Prtsenddata (sendstr, 1 );
4.1.4 cr
[Name] print and press ENTER
[Format] ASCII code cr
Hexadecimal code 0d
Decimal code 13
[Description] print but not feed.
[Note] * after printing, set the start position of the next row to the start position of printing.
[Reference] lf
[Example] char sendstr [2];
Sendstr [0] = 'R'; // in C, 'R' is the carriage return.
Prtsenddata (sendstr, 1 );
15/53
-------- 17 --------
User Manual jpm112 printer development manual (V1.0)
4.1.5 ESC J N
[Name] Printing Documents
[Format] ASCII code ESC J N
Hexadecimal code 1B 4A n
Decimal code 27 74 n
[Range] 0 ≤ n ≤ 255.
[Description] print the data in the output buffer, and run the following n vertices.
[Note] * after printing, set the start position of the next row to the start position of printing.
* The vertical point distance is 0.33mm.
[Reference] ESC d
[Example] char sendstr [4];
Sendstr [0] = 0x1b;
Sendstr [1] = 'J ';
Sendstr [2] = 3;
Prtsenddata (sendstr, 3); // take the paper 1mm
4.1.6 ESC d N
[Name] print X-Paper n rows
[Format] ASCII code ESC d N
Hexadecimal code 1B 64 n
Decimal code 27 100 N
[Range] 0 ≤ n ≤ 255.
[Description] print data in the buffer with N character lines.
[Note] * This command sets the starting position of the print to the starting point of the line.
[Reference] ESC J
[Example] char sendstr [4];
Sendstr [0] = 0x1b;
Sendstr [1] = 'D ';
Sendstr [2] = 2;
Prtsenddata (sendstr, 3); // take two lines of paper
4.1.7 HT
[Name] Move the printing position to the next horizontal tabulation position
[Format] ASCII code HT
Hexadecimal code 09
Decimal code 9
[Description] Move the printing position to the next horizontal tabulation position.
16/53
-------- 18 --------
User Manual jpm112 printer development manual (V1.0)
[Note] * use the esc d command to set the position of the horizontal tab.
* If the next horizontal tabulation position is not set, this command is ignored.
* The default horizontal positioning position is the 8-character width (9,17, 25 ,... Column ).
[Reference] ESC d
[Example] char nextpos = 9;
Prtsenddata ("Product Name", 6 );
Prtsenddata (& nextpos, 1 );
Prtsenddata ("unit price", 4 );
Prtsenddata (& nextpos, 1 );
Prtsenddata ("quantity", 4 );
Prtsenddata (& nextpos, 1 );
Prtsenddata ("amount", 4 );
4.1.8 FS U NL NH
[Name] send data to print in Unicode encoding
[Format] ASCII code FS U NL NH
Hexadecimal code 1C 55 NL NH
Decimal code 28 85 NL NH
[Description] print n (n = NL + NH * 256) Unicode characters.
[Note] * Because Unicode is dubyte encoding, the 2 * n (n = NL + NH * 256) bytes after this command are processed as unicode encoded characters;
* The Chinese characters entered in this command only support the Chinese characters contained in the GBK font and do not include all Chinese characters contained in Unicode;
* For more information about GBK, see the Chinese character internal code extension specification formulated by the National Information Technology Standardization Technical Committee ";
* For more information about Unicode, see the Unicode official website http://www.unicode.org;
* This command is not affected by Chinese Character commands or custom character commands;
* This command can be embedded with other ESC/GS/fs commands, but must adopt unicode encoding.
[Example] char sendstr [64];
Sendstr [0] = 0x1c; sendstr [1] = 'U'; sendstr [2] = 11; sendstr [3] = 0;
Sendstr [4] = 0 × 55; sendstr [5] = 0 × 00; // U + 0055: 'U'
Sendstr [6] = 0x4e; sendstr [7] = 0 × 00; // U + 004e: 'n'
Sendstr [8] = 0x49; sendstr [9] = 0x00; // U + 0049: 'I'
Sendstr [10] = 0 × 43; sendstr [11] = 0 × 00; // U + 0043: 'C'
Sendstr [12] = 0x4f; sendstr [13] = 0 × 00; // U + 004f: 'O'
Sendstr [14] = 0 × 44; sendstr [15] = 0 × 00; // U + 0044: 'D'
Sendstr [16] = 0 × 45; sendstr [17] = 0 × 00; // U + 0045: 'E'
Sendstr [18] = 0 × 53; sendstr [19] = 0 × 62; // U + 6253: 'dapp'
Sendstr [20] = 0 × 70; sendstr [21] = 0 × 53; // U + 5370: 'input'
Sendstr [22] = 0x4b; sendstr [23] = 0x6d; // U + 6d4b: 'test'
Sendstr [24] = 0xd5; sendstr [25] = 0x8b; // U + 8bd5: 'test'
Prtsenddata (sendstr, 26 );
Prtsenddata ("N", 1 );
17/53
-------- 19 --------
User Manual jpm112 printer development manual (V1.0)
4.2 character parameter setting command
4.2.1 ESC! N
[Command] Select print Mode
[Format] ASCII code ESC! N
Hexadecimal code 1B 21 N
Decimal code 27 33 N
[Range] 0 ≤ n ≤ 255.
[Description] select the print mode by specifying the value of N. The N parameter is defined as follows:
Bit Value Meaning
0 0 Spanish character (half width) font A (6 × 12), Chinese character (full width) font A (12 × 12)
1 Spanish character (half width) font B (8 × 16), Chinese character (full width) font B (16 × 16)
1-undefined
2-undefined
3 0 cancel bold Mode
1. Set the bold mode.
4 0 cancel double high Mode
1. Set the double height mode.
5 0 cancel times width Mode
1. Set the double width mode.
6-undefined
7 0 cancel underline Mode
1. Set the underline mode.
[Note] * when both the double height and double width modes are selected, four characters are printed.
* The printer can underline all characters, but it cannot draw any blank space produced by the HT command or Rotate 90 ° clockwise
Line.
* When a row contains several times higher or higher characters, All characters in the row are aligned along the baseline.
* The font of ESC m can also be set. The setting of the last received command is valid.
* You can also set or cancel the bold mode for esc e. The setting of the last received command is valid.
* ESC-You can also set or cancel the underline mode. The setting of the last command received is valid.
* Gs! You can also set the character size. The setting of the last received command is valid.
* This command is valid for English numerals and Chinese characters.
[Default value] n = 0
[Reference] ESC-, esc e, Gs !, ESC m
[Example] char sendstr [4];
Sendstr [0] = 0x1b;
Sendstr [1] = '! ';
Sendstr [2] = 0 × 28; // 00101000 times width in bold
Prtsenddata (sendstr, 3 );
18/53
-------- 20 --------
User Manual jpm112 printer development manual (V1.0)
4.2.2 Gs! N
[Name] enlarged characters
[Format] ASCII code Gs! N
Hexadecimal code 1D 21 N
Decimal code 29 33 N
[Range] 0 ≤ n ≤ 255 (1 ≤ vertical multiples ≤ 2, 1 ≤ horizontal multiples ≤ 2)
[Description] bit 0 ~ 3-character height, 4-digit ~ Select the 7-character width as follows:
0 1 2 3 height 4 5 6 7 width
0 0 0 0 1 times 0 0 0 1 times
1 0 0 0 2 times 1 0 0 2 times
[Note] * This command is valid for all characters (English and Chinese characters.
* If n is out of the defined range, ignore this command.
* The vertical direction refers to the direction of the paper feed, and the horizontal direction is vertical to the direction of the paper feed. However, when the character orientation rotates 90 ° clockwise, the vertical
The relationship between the direction and the horizontal direction is reversed. That is to say, the priority of this command is lower than that of ESC v. When both commands are effective at the same time,
The character is first rotated and then enlarged.
* When a character is enlarged in a line of different sizes, all the characters in a line are aligned along the baseline.
* Use ESC! The command can also set the character size. Set the current mode with the last received command.
[Default value] n = 0
[Reference] ESC!
[Example] char sendstr [4];
Sendstr [0] = 0x1d;
Sendstr [1] = '! ';
Sendstr [2] = 0 × 01; // 00000001 times high
Prtsenddata (sendstr, 3 );
4.2.3 ESC m n
[Name] Select Character Font
[Format] ASCII code ESC m n
Hexadecimal code 1B 4d n
Decimal code 27 77 n
[Range] n = 0, 1, 16, 17,18, 19
[Description] select the character font.
N (decimal) Meaning
0 Spanish character (half width) font (6 × 12)
1 Spanish character (half width) font (8 × 16)
16 simplified Chinese character font 12 × 12
19/53
-------- 21 --------
User Manual jpm112 printer development manual (V1.0)
17 simplified Chinese character font 16 × 16
18 big5 Chinese Character Font 12 × 12
19 big5 Chinese Character Font 16 × 16
[Note] * ESC! You can also set the font. The setting of the last received command is valid.
* When you use this command to set the font. You can set Chinese and Spanish fonts separately, without affecting each other.
[Reference] ESC!
[Example] char sendstr [8];
Sendstr [0] = 0x1b;
Sendstr [1] = 'M ';
Sendstr [2] = 0; // Spanish 6 × 12
Sendstr [0] = 0x1b;
Sendstr [1] = 'M ';
Sendstr [2] = 0 × 11; // Simplified Chinese 16 × 16
Prtsenddata (sendstr, 6); // The Chinese font that will be printed later is 16 × 16, and the western text is 6 × 12.
4.2.4 ESC-n
[Name] Set/cancel underline
[Format] ASCII code ESC-n
Hexadecimal code 1B 2D n
Decimal code 27 45 n
[Range] 0 ≤ n ≤ 2
[Description] Set/remove the underline mode based on the following N values:
N (decimal) Meaning
0. Remove the underline.
1. Set the underline mode (1 point thick)
2. Set the underline mode (2 points thick)
[Note] * The printer cannot print rotation characters and underscores (_) against white characters.
* Changing the character size does not affect the width of the current underline.
* Use ESC! You can also set or remove the underline mode. The final command is valid.
* This command is valid for both English and Chinese characters.
[Default value] n = 0
[Reference] ESC!
[Example] char sendstr [3];
Sendstr [0] = 0x1b;
Sendstr [1] = '-';
Sendstr [2] = 1; // single row underline
Prtsenddata (sendstr, 3 );
20/53
-------- 22 --------
User Manual jpm112 printer development manual (V1.0)
4.2.5 ESC e n
[Name] Set/release bold print
[Format] ASCII code ESC e n
Hexadecimal code 1B 45 n
Decimal code 27 69 n
[Range] 0 ≤ n ≤ 255.
[Description] specifies or removes the bold print mode.
When the nth digit (LSB) is 0, the bold print mode is removed.
When the nth digit (LSB) is 1, the bold print mode is set.
[Note] * only the minimum valid bits of N are allowed.
* Use ESC! You can also set or cancel the bold mode. The final command is valid.
[Default value] n = 0
[Reference] ESC !, ESC g
[Example] char sendstr [3];
Sendstr [0] = 0x1b;
Sendstr [1] = 'E ';
Sendstr [2] = 1; // bold
Prtsenddata (sendstr, 3 );
4.2.6 ESC g N
[Name] Set/remove overlapping Printing
[Format] ASCII code ESC g N
Hexadecimal code 1B 47 n
Decimal code 27 71 n
[Range] 0 ≤ n ≤ 255.
[Description] sets or removes the overlapping printing mode.
When the minimum valid bits (LSB) of N is 0, the overlapping printing mode is removed.
When the minimum valid bits (LSB) of N is 1, the overlapping printing mode is set.
[Note] * only the minimum valid bits of N are allowed.
* The Printer output is the same in overlap mode and in bold mode.
[Default value] n = 0
[Reference] esc e, ESC!
[Example] char sendstr [3];
Sendstr [0] = 0x1b;
Sendstr [1] = 'G ';
Sendstr [2] = 1; // overlaps
Prtsenddata (sendstr, 3 );
21/53
-------- 23 --------
User Manual jpm112 printer development manual (V1.0)
4.2.7 GS B n
[Name] Set/release anti-white print Mode
[Format] ASCII code GS B n
Hexadecimal code 1D 42 n
Decimal code 29 66 n
[Range] 0 ≤ n ≤ 255.
[Description] sets or removes the anti-white print mode.
When the minimum valid bit of N is 0, the anti-white mode is disabled.
When the minimum valid bit of N is 1, the anti-white mode is enabled.
[Note] * only the nth digit is valid.
* This command is valid for both built-in and custom characters.
* When the anti-white mode is enabled, it is also valid for the blank space set by the ESC sp.
* This command does not affect bitmap. the user-defined bitmap, bar code, and bar code display characters are skipped by ht, ESC $, and ESC.
Spacing.
* The anti-white mode takes precedence over the underline mode. When the anti-white mode is selected, it is disabled (but not canceled) even if the underline mode is enabled ).
[Default value] n = 0
[Example] char sendstr [3];
Sendstr [0] = 0x1d;
Sendstr [1] = 'B ';
Sendstr [2] = 1; // anti-white
Prtsenddata (sendstr, 3 );
4.2.8 ESC V N OK
[Name] Set/remove character rotation Mode
[Format] ASCII code ESC V N
Hexadecimal code 1B 56 n
Decimal code 27 86 n
[Range] 0 ≤ n ≤ 3
[Description] setting/removing character rotation Mode
N (decimal) Meaning
0. Release rotation Mode
1. Set the 90 ° clockwise rotation mode.
2. Set the clockwise rotation mode to 180 °.
3. Set the clockwise rotation mode to 270 °.
[Note] * When the underline mode is set, the printer does not underline characters that Rotate 90 ° clockwise.
* In the rotation mode, the direction of the magnification command is the same as that of the magnification command in the general mode.
.
[Default value] n = 0
22/53
-------- 24 --------
User Manual jpm112 printer development manual (V1.0)
[Reference] ESC !, ESC-
[Example] char sendstr [3];
Sendstr [0] = 0x1b;
Sendstr [1] = 'V ';
Sendstr [2] = 2; // rotate 180 degrees
Prtsenddata (sendstr, 3 );
4.3 print typographical parameter setting command
4.3.1 ESC $ NL NH
[Name] sets the absolute printing position
[Format] ASCII code ESC $ NL NH
Hexadecimal code 1B 24 NL NH
Decimal code 27 36 NL NH
[Range] 0 ≤ NL ≤ 255.
0 ≤ NH ≤255
[Description] set the distance from the beginning of a line to the position where the characters to be printed.
The distance from the beginning of a row to the printing position is n horizontal points.
Nl nh is the low and high positions of the Two-byte unsigned integer n, n = NL + NH × 256
[Note] * If the set printing position exceeds the printable area (n> 244), it is set to the maximum value of the printable area (n = 244 ).
[Reference] ESC
[Example] char sendstr [4];
Sendstr [0] = 0x1b;
Sendstr [1] = '$ ';
Sendstr [2] = 15; // 0.2 × 15 = 3
Prtsenddata (sendstr, 3); // The absolute position is set to 3mm (15 horizontal distance) from the left boundary)
Prtsenddata ("print N from 3mm on the left", 22 );
4.3.2 esc d N1 N2... NK null
[Name] set a horizontal Tab
[Format] ASCII code esc d N1... NK null
Hexadecimal code 1B 44 N1... NK 00
Decimal code 27 68 N1... NK 0
[Range] 1 ≤ n ≤ 255 0 ≤ k ≤ 8
[Description] sets the horizontal positioning position.
N specifies the column number starting from a row to set the horizontal positioning position.
K indicates the total number of horizontal positioning points to be set.
[Note] * the horizontal tabulation position is stored as a value. The value is n Spanish characters in width and is measured from the beginning of the row. Character width package