2.2 KiB
Provide a JSON REST API to ESC/POS
printers. Most of the time these printers will be thermal printers.
Usage
GET /api/printer/name
to get the UUID of the printer.
GET /api/printer/status
to get information about the current state of the printer.
To actually print something use POST /api/printer/print
. The body is an JSON array of print instructions. Following instructions are available.
Feed
lines
and dots
can be used at the same time.
{
"type":"feed",
"lines":4,
"dots":50
}
Text
Only text
is required.
alignment
: Can be Right
,Left
,Center
. Default is Left
.
underline
,bold
,doubleHeight
,doubleWidth
are obvious and default to false
.
fontB
: Use different font. Based on printer model. Default is false
.
lineSpacing
: Line spacings in dots. Default is unset.
newLine
: Insert a new line after printing the text. Default is true
.
{
"type":"text",
"text":"Hello world",
"alignment":"Center",
"underline": false,
"bold": false,
"doubleHeight":false,
"doubleWidth":false,
"fontB":false,
"lineSpacing":23,
"newLine":true
}
Barcode
barcode
: Value of the barcode. Depending on the barcodeType
it may only contain numeric characters. Require.
barcodeType
: What type of barcode. Possible values are: CODE128
, UPC_A
,UPC_E
,JAN13_EAN13
,JAN8_EAN8
,CODE39
,ITF
,CODABAR_NW_7
,CODE93
,GS1_128
,GS1_DATABAR_OMNIDIRECTIONAL
, GS1_DATABAR_TRUNCATED
,GS1_DATABAR_LIMITED
,GS1_DATABAR_EXPANDED
. Default is CODE128
. Depending on the printer modell not all types are supported.
barcodeCode
: I honestly have no idea what exactly this changes. But it changes something. Default is CODE_B
.
alignment
: Just like alignment
in the "Text" instruction.
labelPos
: Position of the value of the barcode in text form. Possible values are : None
, Above
, Below
, Both
. Default is Below
.
height
: Height of the barcode in dots. Default is unset.
{
"type":"barcode",
"barcode":"348234445AA",
"barcodeType":"CODE128",
"barcodeCode":"CODE_B",
"alignment":"Center",
"labelPos":"None",
"height":45,
}