A Ticketfile is Unicode text encoded in UTF-8, it contains a set of commands.
Those commands allow you to write to the receipt, cut the paper, define styles, etc.
At the moment specification are still subject to change based on usage feedbacks. They'll get more stable after a few months.
The present specification use the Extended Backus-Naur Form. More precisely, the syntax follows the Golang specification notation.
Ticketfile comments are single-line :
comment = "#" { unicode_char } .
The INIT command clears the print buffer and resets modes to their default values.
It basically sets the printer in the same state as it would be right after powering it up.
It should typically be at the beginning of a Ticketfile, so that states and styles from previous Ticketfiles are discarded.
init_command = "INIT" .
Those commands print text and control line feeds.
print_command = "PRINT" unicode_char { unicode_char } .
lf_command = "LF" { decimal_lit } .
printlf_command = "PRINTLF" unicode_char { unicode_char } .
printraw_command = "PRINTRAW" newline { unicode_char | "\n" } newline ">>>" .
For example :
# First row
PRINT Hello
LF 2
# Third row
PRINTLF world
PRINTRAW
This text can contain newlines.
This is useful if for instance you're using templating on top of Ticketfiles
and have multi-line variables to display.
>>>
Set alignement for the text.
align_command = "ALIGN" ( "LEFT" | "CENTER" | "RIGHT" ) .
Example :
ALIGN RIGHT
PRINTLF To the right!
ALIGN CENTER
PRINTLF This is centered.
Sets the vertical and horizontal motion units.
byte_decimal_lit = "0" … "255" .
units_command = "UNITS" byte_decimal_lit byte_decimal_lit .
The first argument corresponds to the horizontal motion unit, the second to the vertical motion unit. Those units are used for print position related commands, such as MARGINLEFT
.
The resulting motion in inches is the multiplicative inverse of the provided value. For example :
UNITS 2 0
Here the horizontal motion unit would be 1 / 2 inches
(approximately 12.7 mm).
The zero value for the vertical motion unit indicates that it should use the printer's default.
This command will most likely change in the future, as it's currently not abstracted from ESC/POS.
Sets left margin.
two_bytes_decimal_lit = "0" … "65535" .
margin_command = "MARGINLEFT" two_bytes_decimal_lit .
The argument is a number from 0 to 65535, the actual resulting margin is :
margin * horizontal_motion_unit
.
Example :
UNITS 2 0
MARGINLEFT 3
Here the horizontal motion unit is 2, hence the margin would be 3 * 1 / 2
inches (approximately 38.1 mm).
This command will most likely change in the future, as it's currently not abstracted from ESC/POS.
Sets font style.
font_command = "FONT" ( "A" | "B" | "C" ) .
A is the default one, B is usually smaller text.
Sets text color. Black is the default color, some models support an additional color (usually red).
color_command = "COLOR" ( "BLACK" | "RED" ) .
Sets the charset. The default is PC437 (USA: Standard Europe).
charset_command = "CHARSET" ( "PC437" | "PC850" | "PC860" | "PC863" | "PC865" ) .
Cuts paper, default mode is FULL, PARTIAL would left one point uncut.
cut_command = "CUT" [ "PARTIAL" | "FULL" ] .