Cloud Printer Product R&D Instruction

6.Printer common ESC/POS command set

  • LF Print and line feed
ContentSpecification
[Format]ASCII:LF
Hex:0A
Decimal:10
[Description]· Print the data in the buffer and line feed under the standard mode
[Note]· This command places the current position at the beginning in the line
  • ESC ! n select print mode
ContentSpecification
[Format]ASCII:ESC ! n
Hex:1B 21 n
Decimal:27 33 n
[Range]0≤n≤255
[Description]Set the print mode of characters according to the value of n
n=0font in standard size
n=16font in double height
n=32font in double width
n=48font in double height and double width
[注释]· All characters are bottom aligned
· Valid for both English letters, numbers and Chinese characters
[默认值]n=0
  • ESC a n select alignment
ContentSpecification
[Format]ASCII:ESC a n
Hex:1B 61 n
Decimal:27 97 n
[Range]0≤n≤2 or 48≤n≤50
[Description]A line of data is aligned per the value of n:
0,48 Left alignment
1,49 Center
2,50 Right alignment
[Note]· In standard mode, this command is only effective at the beginning in a line
· This command sets the alignment rule at the print area
[Default]n=0
  • ESC p m t1 t2 open a cash drawer with drive pulse
ContentSpecification
[Format]ASCII:ESC p m t1 t2
Hex:1B 70 m t1 t2
Decimal:27 112 m t1 t2
[Rane]m = 0, 1, 48, 49
0 ≤ t1 ≤ 255
0 ≤ t2 ≤ 255
[Description]· m=0, 48 Cash box socket pin 2;m=1, 49 Cash box socket pin 5
· t1 specifies the drive pulse start time[ t1 × 2 ms].
· t2 specifies the drive pulse end time[ t2 × 2 ms].
[注释]· t1 must be smaller than t2 to make the end time larger than the start time < td="" style="box-sizing: border-box;">
  • GS V m Cutting paper
ContentSpecification
[Format]ASCII:GS V m
Hex:1D 56 m
Decimal:29 86 m
[Range]m=1, 49
[Description]· Select a mode to cut paper
[Note]· The modes to cut paper vary per the paper cutter types
· This command is only effective when it is processed at the beginning in a line
· The paper won’t be cut out completely
  • GS H n select where to print barcode characters
ContentSpecification
[Format]ASCII:GS H n
Hex:1D 48 n
Decimal:29 72 n
[Range]0≤n≤3 or 48≤n≤51
[Description]Select where to print barcode characters when printing a barcode
n specifies the position to print barcode characters:
0,48 do not print
1,49 above the barcode
2,50 below the barcode
3,51 above and below the barcode
[Default]n = 0
  • GS h n select the height of a barcode
ContentSpecification
[Format]ASCII:GS h n
Hex:1D 68 n
Decimal:29 104 n
[Range]1≤n≤255
[Description]· Set the vertical height of a barcode per n (the number of dots vertically placed. 0.125mm/dot)
[Default]n= 162
  • GS w n set the width of a barcode
ContentSpecification
[Format]ASCII:GS w n
Hex:1D 77 n
Decimal:29 119 n
[Range]1≤n≤6
[Description]· Set the horizontal width of a barcode
[Default]n=3
  • GS k m n d1…dn print barcode
ContentSpecification
[Format]ASCII:GS k m n d1…dk
Hex:1D 6B m n d1…dk
Decima:29 107 m n d1…dk
[Range]65≤ m ≤89(the length of d1…dn depends on the barcode system used)
[Description]· Select a barcode system and print
[Note]· n indicates the number of barcode data, and printer processes the n-byte data following as barcode data
· If n exceeds the specified range, the printer will stop processing this command and process the following data as normal data
· The command will be invalid if the barcode data d exceeds the specified range
· If the width of the barcode exceeds the width of a print area, it will be invalid
· No matter how high the line is set by the ESC2 or ESC3 command, the paper distance is the same as the bar code height
· This command is only effective when there is no data in the buffer, otherwise the command will be neglected
· After printing the barcode, set the print position at the beginning in a line

The selected barcode systems for m are:

mBarcode systemData lengthNumber of charactersCharacterRange
65UPC-AFixed11≤n≤120~948≤d≤57
66UPC-EFixed6≤n≤70~948≤d≤57
67JAN13(EAN13)Fixed12≤n≤130~948≤d≤57
68JAN8(EAN8)Fixed7≤n≤80~948≤d≤57
69CODE39Variable1≤n≤640~9, A~Z, SP, $,
%, *, +, -, ., /
48≤d≤57, 65≤d≤90, 32,
36, 37, 43, 45, 46, 47
70Code 2 of 5 InterleavedVariable2≤n≤64
(even number)
0~948≤d≤57
71CODABARVariable1≤n0~9, A~D, a~d,
$, +, -, ., /, :
48≤d≤57, 65≤d≤68, 97≤d≤100,
36, 43, 45, 46, 47, 58,
65≤d1≤68, 97≤d1≤100,
65≤dk≤68, 97≤dk≤100
72CODE93Variable1≤n≤64
73CODE128Variable2≤n≤64
81Code 2 of 5 MatrixVariable1≤n≤640~948≤d≤57
82Code 2 of 5 IndustrialVariable1≤n≤640~948≤d≤57
83Code 2 of 5 IATAVariable1≤n≤640~948≤d≤57
84Code 2 of 5 DatalogicVariable1≤n≤640~948≤d≤57
85CODE11Variable1≤n≤640~9, –48≤d≤57,45
86CODE39 xtendedVariable1≤n≤64
87GS1 DataBarFixedn=130~948≤d≤57
88GS1 DataBar ExpandedVariable
89MSI PlesseyVariable1≤n≤640~948≤d≤57
  • GS v 0 m xL xH yL yH d1….dk Print raster bit image
ContentSpecification
[Format]ASCII:GS v 0 m xL xH yL yH d1…dk
Hex:1D 76 30 m xL xH yL yH d1…dk
Decimal:29 118 48 m xL xH yL yH d1…dk
[Range]0 ≤ m ≤ 3, 48 ≤ m ≤ 51
0 ≤ xL ≤ 255
0 ≤ xH ≤ 255 ; The 1≤(xL+xH×256)≤128
0 ≤ yL ≤ 255
0 ≤ yH ≤ 8 ; The 1≤(xL+xH×256)≤4095
0 ≤ d ≤ 255
k = (xL+xH×256) × (yL+yH×256);(k≠0)
[Description]• m,Selects Raster bit-image mode
• xL, xH,select the number of data bits (xL+xH´256) in the horizontal direction for the bit image
• yL, yH,select the number of data bits (yL+yH´256) in the vertical direction for the bit image.
[Note]• In standard mode, this command is effective only when there is no data in the print buffer. 
• This command has no effect in all print modes (character size, emphasized, double-strike, upside-down, underline, white/black reverse printing, etc.) for raster bit image. 
• Data outside the printing area is read in and discarded on a dot-by-dot basis. 
• The ESC a (Select justification) setting is also effective on raster bit images.
• When this command is received during macro definition, the printer ends macro definition, and begins performing this command. The definition of this command should be cleared.

The value of m selects the mode, as follows:

mModeVertical Dot Density (DPI)Horizontal Dot Density (DPI)
0, 48Normal203.2dpi203.2dpi
1, 49Double-width203.2dpi101.6dpi
2, 50Double-height101.6dpi203.2dpi
3, 51Quadruple101.6dpi101.6dpi

Print raster bit image demo:

• Assume that there is an bit image with 32 pixels width and 32 pixels height to be printed in quadruple, then the printed image is 64×64.
We have m=3, xL=4, xH=0, yL=32, yH=0. Please refer to picture for the arrangement of dk.

• The instruction data should be:
GS v 0 3D 4D 0D 32D 0D FFH 00H FFH 00H 00H FFH 00H FFH FFH 00H FFH 00H 00H FFH 00H FFH FFH 00H FFH 00H 00H FFH 00H FFH FFH 00H FFH 00H 00H FFH 00H FFH FFH 00H FFH 00H 00H FFH 00H FFH FFH 00H FFH 00H 00H FFH 00H FFH FFH 00H FFH 00H 00H FFH 00H FFH FFH 00H FFH 00H 00H FFH 00H FFH FFH 00H FFH 00H 00H FFH 00H FFH FFH 00H FFH 00H 00H FFH 00H FFH FFH 00H FFH 00H 00H FFH 00H FFH FFH 00H FFH 00H 00H FFH 00H FFH FFH 00H FFH 00H 00H FFH 00H FFH FFH 00H FFH 00H 00H FFH 00H FFH FFH 00H FFH 00H 00H FFH 00H FFH FFH 00H FFH 00H 00H FFH 00H FFH LF LF LF LF
• Coverted into hexadecimal:
1D76300304002000FF00FF0000FF00FFFF00FF0000FF00FFFF00FF0000FF00FFFF00FF0000FF00FFFF00FF0000FF00FFFF00FF0000FF00FFFF00FF0000FF00FFFF00FF0000FF00FFFF00FF0000FF00FFFF00FF0000FF00FFFF00FF0000FF00FFFF00FF0000FF00FFFF00FF0000FF00FFFF00FF0000FF00FFFF00FF0000FF00FFFF00FF0000FF00FF0A0A0A0A