Skip to content

Not able to open cash drawer using command. #121

@amrutakawale

Description

@amrutakawale

Hi,

I am using 'electron-pos-printer' to print receipts in my Windows electron app, but cash drawer functionality is not working as expected.
Expected behaviour: The cash drawer should open only for cash/cheque payment methods.
Current behaviour: The cash drawer is opened for all payment methods. I am using STAR TSP100 Cutter printer.
I reached out to the Star Support Team, and they suggested the below code:

Image

My current implementation is:

const { PosPrinter } = require("electron-pos-printer");

ipcMain.on("printOrderInfo", (event, count, printContent, isCashOrCheck) => {
const printers = mainWindow.webContents.getPrinters();
let printerInfo = printers.find((printer) =>
printer.name.includes("Star TSP100 Cutter")
);

if (!printerInfo) {
console.log("Star TSP100 Cutter Printer is not available for Print.");
return;
}

const options = {
preview: false, // Preview in window or print
width: "100%" , // width of content body
margin: "0 0 0 0" , // margin of content body
copies: 1, // Number of copies to print
printerName: printerInfo.name, // printerName: string, check it at webContent.getPrinters()
timeOutPerLine: 400,
silent: true,
};

for (let index = 0; index < count; index++) {
const data = [
{
type: "text", // 'text' | 'barCode' | 'qrCode' | 'image' | 'table'
value: printContent[index],
css: {
"text-align": "center",
},
},
];
PosPrinter.print(data, options)
.then(() => {})
.catch((error)=> {
console.error("Failed to Print. Please try again. " + error);
});
}
});

I want to trigger a command to open a cash drawer with the type "raw" As the Star team suggested.

Could you please help me with that?

Thank you in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions