Klemen1337 / node-thermal-printer

Node.js module for Epson, Star, Tanca, Drauma and Brother thermal printers command line printing.
MIT License
778 stars 244 forks source link

await execute() leaves job in queue on Star MC-Print3 #258

Open pr1ntr opened 3 months ago

pr1ntr commented 3 months ago

Testing with this code:

import printer from '@woovi/node-printer'
import { ThermalPrinter, PrinterTypes, CharacterSet, BreakLine } from 'node-thermal-printer'

const PRINTER_NAME = 'Star MCP30'

const device = new ThermalPrinter({
  type: PrinterTypes.STAR,
  interface: `printer:${PRINTER_NAME}`,
  characterSet: CharacterSet.ISO8859_2_LATIN2,
  lineCharacter: '═',
  breakLine: BreakLine.WORD,
  driver: printer,
  options: {
    timeout: 1000
  }
})

let isConnected = await device.isPrinterConnected()

async function printFromDevice() {
  if(isConnected) {
    device.newLine()
    device.newLine()
    device.println("Hello World")
    device.println("Hello World")
    device.println("Hello World")
    device.println("Hello World")
    device.newLine()
    device.partialCut()

    try {
      await device.execute()
    } catch(err) {
      console.error(err)
    }
  }
}
printFromDevice()

after it prints it just sits in the queue image

Klemen1337 commented 2 months ago

Check if printer requires a response. Some printers wait for a specific command to be sent. This feature can be disabled in printer drivers