Fork of Klemenn1337/node-thermal-printer with more features for Star thermal printers. For added features see Added Features Section
npm install star-thermal-printer
Linux requires build-essentials
sudo apt-get install build-essential
When using inside a browser, the network interface will not work as browsers do not allow opening TCP sockets.
You still need to instruct the compiler to ignore node dependencies. For webpack, it can be done like this:
new webpack.IgnorePlugin({
resourceRegExp: /^fs$|^net$/,
}),
Refer to Original Readme
printer.setTextSize(5,5); // Set text height (0-5) and width (0-5)
import { Errors } from "star-thermal-printer"
printer.execute({waitForResponse: true})
.then((data) => {
let errorReadFromPrinter = printer.parseStatusRT(data);
console.log(errorReadFromPrinter); // Error.PAPER_END, Error.PAPER_NEAR_END, Error.NONE
})
.catch((error) => {
console.log('Printing error: ' + error)
});