node-thermal-printer
Node.js module for EPSON and STAR thermal printers command line printing.
Installation
Dependency requires build-essentials
sudo apt-get install build-essential
$ npm install node-thermal-printer
Features
printer; printer // Check if printer is connected, callback passes bool of statusprinter; // Executes all the commands. Optional callback returns null if no error, else error messageprinter; // Print instantly. Optional callback returns null if no error, else error messageprinter; // Append textprinter; // Append text with new lineprinter; // Kick the cash drawerprinter; // Cuts the paper (if printer only supports one mode use this)printer; // Cuts the paper leaving a small bridge in middle (if printer supports multiple cut modes)printer; // Sound internal beeper/buzzer (if available)printer; // Content is printed upside down (rotated 180 degrees) printer; // Set text boldprinter; // Background/text color inversionprinter; // Underline text (1 dot thickness)printer; // Underline text with thick line (2 dot thickness)printer; // Draws a lineprinter; // Insers break line printer; // Align text to centerprinter; // Align text to leftprinter; // Align text to right printer; // Set font type to A (default)printer; // Set font type to B printer; // Set text to normalprinter; // Set text to double heightprinter; // Set text to double widthprinter; // Set text to quad area printer; // Prints text left and rightprinter; // Prints table equalyprinter; printer; // Print code128 bar codeprinter; // Print QR codeprinter; // Print PNG image (uses callback) printclear; // Clears printText valueprint; // Returns printer buffer string valueprint; // Returns printer bufferprint; // Get number of characters in one line
Examples
var printer = ;printer;printer;printer;printerprinter;
2D Barcode Examples
Example settings are the default when not specified.
printer; printer; printer; printer;
1D Barcode Example
var data = "GS1-128" // Barcode data (string or buffer)var type = 74 // Barcode type (See Reference)var settings = // Optional Settings hriPos: 0 // Human readable character 0 - 3 (none, top, bottom, both) hriFont: 0 // Human readable character font width: 3 // Barcode width height: 168 // Barcode height printer;
Epson Barcode Reference
# | Type | Possible Characters | Length of Data |
---|---|---|---|
65 | UPC-A | 0 - 9 | 11, 12 |
66 | UPC-E | 0 - 9 | 6 – 8, 11, 12 |
67 | JAN13 | 0 - 9 | 12, 13 |
68 | JAN8 | 0 - 9 | 7, 8 |
69 | Code39 | 0 – 9, A – Z, SP, $, %, *, +, -, ., / | 1 – 255 |
70 | ITF (Interleaved 2 of 5) | 0 – 9 | 2 – 254 (even number) |
71 | CODABAR (NW-7) | 0 – 9, A – D, a – d, $, +, −, ., /, : | 2 – 255 |
72 | CODE93 | 00h – 7Fh | 1 – 255 |
73 | CODE128 | 00h – 7Fh | 2 - 255 |
74 | GS1-128 | NUL – SP(7Fh) | 2 – 255 |
75 | GS1 DataBar Omnidirectional | 0 – 9 | 13 |
76 | GS1 DataBar Truncated | 0 – 9 | 13 |
77 | GS1 DataBar Limited | 0 – 9 | 13 |
78 | GS1 DataBar Expanded | 0 – 9, A – D, a – d, SP, !, ", %, $, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, _, { | 2 - 255 |
Docs
- STAR: http://www.starmicronics.com/support/mannualfolder/starline_cm_rev1.15_en.pdf
- EPSON: https://reference.epson-biz.com/modules/ref_escpos/index.php
Tested printers:
- Star TSP700
- Rongta RP80US