Compare commits
3 Commits
1c5f46b94b
...
f7b41cf647
| Author | SHA1 | Date | |
|---|---|---|---|
| f7b41cf647 | |||
| 2b9f62b239 | |||
| 1db2e55b2b |
@@ -18,7 +18,7 @@ public class BarcodeInstruction : BaseInstruction
|
||||
public Alignment alignment {get; set; } = Alignment.Left;
|
||||
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public BarLabelPrintPosition lablePos {get; set; } = BarLabelPrintPosition.Below;
|
||||
public BarLabelPrintPosition labelPos {get; set; } = BarLabelPrintPosition.Below;
|
||||
|
||||
// [JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
// public BarWidth width { get; set; } = BarWidth.Default;
|
||||
@@ -36,8 +36,8 @@ public class BarcodeInstruction : BaseInstruction
|
||||
|
||||
commands.Add(alignmentCommand(alignment));
|
||||
|
||||
if (lablePos != BarLabelPrintPosition.Below){
|
||||
commands.Add(e.SetBarLabelPosition(lablePos));
|
||||
if (labelPos != BarLabelPrintPosition.Below){
|
||||
commands.Add(e.SetBarLabelPosition(labelPos));
|
||||
}
|
||||
|
||||
if (height > 0)
|
||||
|
||||
@@ -15,7 +15,7 @@ public class TextInstruction : BaseInstruction
|
||||
public bool doubleHeight {get; set; } = false;
|
||||
public bool doubleWidth {get; set; } = false;
|
||||
public bool fontB {get; set; } = false;
|
||||
|
||||
public int lineSpacing {get; set; } = -1;
|
||||
|
||||
public bool newLine { get; set; } = true;
|
||||
|
||||
@@ -27,6 +27,10 @@ public class TextInstruction : BaseInstruction
|
||||
|
||||
commands.AddRange(setStyles());
|
||||
|
||||
if (lineSpacing >= 0){
|
||||
commands.Add(e.SetLineSpacingInDots(lineSpacing));
|
||||
}
|
||||
|
||||
if (newLine)
|
||||
{
|
||||
commands.Add(e.PrintLine(text));
|
||||
@@ -40,6 +44,10 @@ public class TextInstruction : BaseInstruction
|
||||
commands.Add(e.SetStyles(PrintStyle.None));
|
||||
}
|
||||
|
||||
if (lineSpacing >= 0){
|
||||
commands.Add(e.ResetLineSpacing());
|
||||
}
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
|
||||
76
README.md
Normal file
76
README.md
Normal file
@@ -0,0 +1,76 @@
|
||||
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.
|
||||
|
||||
```json
|
||||
{
|
||||
"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`.
|
||||
|
||||
```json
|
||||
{
|
||||
"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.
|
||||
|
||||
```json
|
||||
{
|
||||
"type":"barcode",
|
||||
"barcode":"348234445AA",
|
||||
"barcodeType":"CODE128",
|
||||
"barcodeCode":"CODE_B",
|
||||
"alignment":"Center",
|
||||
"labelPos":"None",
|
||||
"height":45,
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user