Open atulatulatul opened 1 year ago
have you found any solutions or alternatives ?
have you found any solutions or alternatives ?
This is one of the alternatives that worked for me. My original plan is to run node-thermal-printer
without @thiagoelg/node-printer
because the latter didn't get installed in my electron app.
let tp = new ThermalPrinter({
type: PrinterTypes.EPSON, // Printer type: 'star' or 'epson'
interface: "printer:Xprinter XP-T371U", // Printer interface
characterSet: CharacterSet.ISO8859_2_LATIN2, // Printer character set
options: {
timeout: 5000, // Connection timeout (ms) [applicable only for network printers] - default: 3000
},
driver: {}, // Empty object
});
tp.println("Hello World");
tp.table(["One", "Two", "Three"])
tp.cut();
const raw = tp.getBuffer()
let device = usb.findByIds(/*vid*/8137, /*pid*/8214);
if (device) {
device.open();
console.log(device.interfaces?.at(0)?.endpoints)
device.interfaces?.at(0)?.claim();
const outEndpoint = device.interfaces?.at(0)?.endpoints.find(e => e.direction === 'out');
if (outEndpoint) {
outEndpoint.transferType = 2;
outEndpoint.transfer(raw, (err) => {
device.close();
});
}
}
What's the issue?
Hi. I just wanted to know what should be set as the
driver
.I just wanted to open the cash drawer attached to the printer
XP-80C
(almost similar toEPSON
), I've already tried the following packages:@flovy/node-printer
@thiagoelg/node-printer
When using the above packages as driver whenever I execute this line of code:
The entire electron app crashes and goes blank.
https://user-images.githubusercontent.com/13715884/219932018-616f5ba0-57c6-45b6-af6f-d9977bda6071.mp4