i have done this code but it ask for driver while printing from usb
const { printer: ThermalPrinter, types: PrinterTypes } = require("node-thermal-printer");
let printer = new ThermalPrinter({
type: PrinterTypes.EPSON,
interface: 'printer:4BARCODE 3B-303B',
});
printer.println("Hello World");
printer.cut();
printer.execute();
i have also given driver from @thiagoelg/node-printer
but it prints only work on receipt printer not i label printer.
How can i get print from label printer using usb
Answer
Receipt printers uses protocol ESC/POS, which is what node-thermal-printer outputs. Label printers uses other protocols like TSPL, ZPL, EPL, DPL.
Find the protocol your label printer uses (the printing language) from the manual or manufacturer's website.
Then send the raw print language instructions in your code. Here is example for TSPL/ZPL commands over USB on windows:
const printer = require("@thiagoelg/node-printer");
let labelCommand = `
SIZE 40 mm,30 mm
GAP 2 mm,0
DIRECTION 1
CLS
TEXT 100,100,"3",0,1,1,"Hello Label"
PRINT 1
`;
printer.printDirect({
data: labelCommand,
printer: '4BARCODE 3B-303B',
type: 'RAW',
success: function (jobID) {
console.log("Print job sent with ID:", jobID);
},
error: function (err) {
console.error("Print error:", err);
}
});