Skip to content

Instantly share code, notes, and snippets.

@kobkrit
Created July 19, 2017 14:17
Show Gist options
  • Save kobkrit/88131ff8b036842d17d398a45e0f6528 to your computer and use it in GitHub Desktop.
Save kobkrit/88131ff8b036842d17d398a45e0f6528 to your computer and use it in GitHub Desktop.
Thermal
var thermal_printer = require(“node-thermal-printer”);
var printer = require(“printer”);
// console.log(printer.getPrinters())
var star = printer.getPrinter(‘Star_TUP992__STR_T_U001_‘);
thermal_printer.init({
type:‘star’
})
thermal_printer.println(“Hello World”);
thermal_printer.alignRight(); // Align text to right
thermal_printer.drawLine();
console.log(printer.getPrinterDriverOptions(‘Star_TUP992__STR_T_U001_‘))
printer.printDirect({
data: thermal_printer.getBuffer(),
printer: star.name,
type: “TEXT”,
success: function(job_id){
console.log(‘OK :‘+job_id);
},
error: function(err){
console.error(err);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment