Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-thermal-printer-poetic

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-thermal-printer-poetic

Made to work with Epson and Star thermal printers

  • 1.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

node-thermal-printer

Node.js module for EPSON and STAR thermal printers command line printing.

Join the chat at https://gitter.im/Klemen1337/node-thermal-printer

Installation

Dependency requires build-essentials

sudo apt-get install build-essential
$ npm install node-thermal-printer

Features

printer.init({
  type: 'star',                                     // Printer type: 'star' or 'epson'
  interface: '/dev/usb/lp0',                        // Printer interface
  characterSet: 'SLOVENIA',                         // Printer character set
  removeSpecialCharacters: false,                   // Removes special characters - default: false
  replaceSpecialCharacters: true,                   // Replaces special characters listed in config files - default: true
  extraSpecialCharacters:{'£':163}                  // Adds additional special characters to those listed in the config files
});

printer.isPrinterConnected( function(isConnected){ } )     // Check if printer is connected, callback passes bool of status
printer.execute( function(err){ } );                       // Executes all the commands. Optional callback returns null if no error, else error message
printer.raw(new Buffer("Hello world"), function(err){ } ); // Print instantly. Optional callback returns null if no error, else error message
printer.print("Hello World");                              // Append text
printer.println("Hello World");                            // Append text with new line
printer.openCashDrawer();                                  // Kick the cash drawer
printer.cut();                                             // Cuts the paper (if printer only supports one mode use this)
printer.partialCut();                                      // Cuts the paper leaving a small bridge in middle (if printer supports multiple cut modes)
printer.beep();                                            // Sound internal beeper/buzzer (if available)
printer.upsideDown(true);                                  // Content is printed upside down (rotated 180 degrees)

printer.bold(true);                                 // Set text bold
printer.invert(true);                               // Background/text color inversion
printer.underline(true);                            // Underline text (1 dot thickness)
printer.underlineThick(true);                       // Underline text with thick line (2 dot thickness)
printer.drawLine();                                 // Draws a line
printer.newLine();                                  // Insers break line

printer.alignCenter();                              // Align text to center
printer.alignLeft();                                // Align text to left
printer.alignRight();                               // Align text to right

printer.setTypeFontA();                             // Set font type to A (default)
printer.setTypeFontB();                             // Set font type to B

printer.setTextNormal();                            // Set text to normal
printer.setTextDoubleHeight();                      // Set text to double height
printer.setTextDoubleWidth();                       // Set text to double width
printer.setTextQuadArea();                          // Set text to quad area

printer.leftRight("Left", "Right");                 // Prints text left and right
printer.table(["One", "Two", "Three"]);             // Prints table equaly
printer.tableCustom([                               // Prints table with custom settings (text, align, width, bold)
  { text:"Left", align:"LEFT", width:0.5 },
  { text:"Center", align:"CENTER", width:0.25, bold:true },
  { text:"Right", align:"RIGHT", width:0.25 }
]);

printer.code128("Code128");                         // Print code128 bar code
printer.printQR("https://github.com/Klemen1337/node-thermal-printer"); // Print QR code
printer.printImage('./assets/olaii-logo-black.png', function(done){ }); // Print PNG image (uses callback)

print.clear();                                      // Clears printText value
print.getText();                                    // Returns printer buffer string value
print.getBuffer();                                  // Returns printer buffer
print.getWidth();                                   // Get number of characters in one line

Examples

var printer = require("node-thermal-printer");
printer.init({
  type: 'epson',
  interface: '/dev/usb/lp0'
});
printer.alignCenter();
printer.println("Hello world");
printer.printImageBuffer(/* PNG image buffer */, function(done){})
printer.printImage('./assets/olaii-logo-black.png', function(done){
  printer.cut();
  printer.execute(function(err){
    if (err) {
      console.error("Print failed", err);
    } else {
     console.log("Print done");
    }
  });
});

2D Barcode Examples

Example settings are the default when not specified.

printer.code128("Code128", {
    width: "LARGE",          // "SMALL", "MEDIUM", "LARGE",
    height: 80,              // 50 < x < 80
    text: 2,                 // 1 - No text
                             // 2 - Text on bottom
                             // 3 - No text inline
                             // 4 - Text on bottom inline
});

printer.printQR("QR Code", {
    cellSize: 3,             // 1 - 8
    correction: 'M',         // L(7%), M(15%), Q(25%), H(30%)
    model: 2,                // 1 - Model 1
                             // 2 - Model 2 (standard)
                             // 3 - Micro QR
});

printer.pdf417("PDF417", {
    rowHeight: 3,            // 2 - 8
    width: 3,                // 2 - 8
    correction: 1,           // Ratio: 1 - 40
    truncated: false,        // boolean
    columns: 0               // 1 - 30, 0 auto
});

printer.maxiCode("MaxiCode", {
    mode: 4,                 // 2 - Formatted/structured Carrier Message (US)
                             // 3 - Formatted/structured Carrier Message (International)
                             // 4 - Unformatted data with Standard Error Correction.
                             // 5 - Unformatted data with Enhanced Error Correction.
                             // 6 - For programming hardware devices.
});

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.printBarcode(data, type, settings);

Epson Barcode Reference

#TypePossible CharactersLength of Data
65UPC-A0 - 911, 12
66UPC-E0 - 96 – 8, 11, 12
67JAN130 - 912, 13
68JAN80 - 97, 8
69Code390 – 9, A – Z, SP, $, %, *, +, -, ., /1 – 255
70ITF (Interleaved 2 of 5)0 – 92 – 254 (even number)
71CODABAR (NW-7)0 – 9, A – D, a – d, $, +, −, ., /, :2 – 255
72CODE9300h – 7Fh1 – 255
73CODE12800h – 7Fh2 - 255
74GS1-128NUL – SP(7Fh)2 – 255
75GS1 DataBar Omnidirectional0 – 913
76GS1 DataBar Truncated0 – 913
77GS1 DataBar Limited0 – 913
78GS1 DataBar Expanded0 – 9, A – D, a – d, SP, !, ", %, $, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, _, {2 - 255

Docs

Tested printers:

  • Star TSP700
  • Rongta RP80US

Keywords

FAQs

Package last updated on 08 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc