-
Notifications
You must be signed in to change notification settings - Fork 262
Open
Description
import { ThermalPrinter, PrinterTypes } from "node-thermal-printer";
export const printReceipt = async () => {
try {
console.log("Initializing printer...");
let printer = new ThermalPrinter({
type: PrinterTypes.EPSON,
interface: "printer:TM-T82", // Ensure it's exactly as shown in Get-Printer
driver: "printer" // Explicitly set the driver
});
const isConnected = await printer.isPrinterConnected();
console.log("Printer connected:", isConnected);
if (!isConnected) {
console.error("Printer not connected!");
return { success: false, message: "Printer not connected" };
}
printer.alignCenter();
printer.bold(true);
printer.println("π₯ Hi π₯");
printer.bold(false);
printer.cut();
console.log("Sending print job...");
await printer.execute();
console.log("Print job sent!");
return { success: true, message: "Printed successfully" };
} catch (error) {
console.error("Printing error:", error);
return { success: false, message: "Printing failed", error: error.message };
}
};
what can i do the npm printer
and in later node there is some prblems
// Run the function
printReceipt();
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels