port-thermal-printer v0.1.1
Node Port Thermal Printer
This is a package for print text to thermal printers by the local port. Designed to work with Windows and Linux, saving text as a file into temp system folder and send to print by serial port using native command lines. Works only with sync methods for wait response.
Installation
Install Port Thermal Printer with npm
npm install port-thermal-printer
Usage/Examples
Print a text
This is the simplest use of this library. Basically, import the library port-thermal-printer, and execute the method this.printDirect();
, giving the port and the text do you want to print as parameter. If the port or text given are empty, the printDirect will throws an Param required
exception.
const portPrinter = require('port-thermal-printer');
try {
portPrinter.printDirect(port, text);
} catch (err) {
console.log(err.message);
}
Validate port
If you want to check or validate a serial port, you can pass the port to the this.validatePort();
method as parameter. The library returns true or false if found the serial port.
const portPrinter = require('port-thermal-printer');
try {
portPrinter.validatePort(port);
} catch (err) {
console.log(err.message);
}
Authors
- Juan Diego Granada