Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] - Silent Print not wokring. #113

Open
zain-335 opened this issue Dec 4, 2023 · 6 comments
Open

[Fix] - Silent Print not wokring. #113

zain-335 opened this issue Dec 4, 2023 · 6 comments

Comments

@zain-335
Copy link

zain-335 commented Dec 4, 2023

I'm using @3ksy/electron-pos-printer lib inside my electron react project to print receipts from main-process(nodejs).
Printer is working only when slient: false. when i set the silent: true inside PrintOptions, it prints empty receipts.
here is my code.

import { PosPrinter, PosPrintData, PosPrintOptions } from '@3ksy/electron-pos-printer'

const options: PosPrintOptions = {
  preview: false,
  margin: '0 0 0 0',
  boolean: '',
  copies: 1,
  timeOutPerLine: 400,
  pageSize: '80mm', // page size,
  silent: true
}

export const handlePrintReceipt = async (_, data: PosPrintData[]) => {
  PosPrinter.print(data, options)
    .then(console.log)
    .catch((error) => {
      console.log('hello error')
      console.error(error)
    })
}

Current Response

Printer not printing any content when silent: true but printing all the content as expected when silent: false.

Expected Result

Printer should print content when setting silent : true in PrintOptions

@alfianlensundev
Copy link

i have the same problem

@ranulrandombage
Copy link

ranulrandombage commented Dec 29, 2023

Having the same issue prints nothing but the paper cuts.

@aldoanizio
Copy link

I have the same problem here

@aldoanizio
Copy link

Hi @zain-335 @alfianlensundev @ranulrandombage I found the reason for this "bug". It's not related to the library but the electron itself.

Looks like the electron versions after 24x does not print the content when the silent mode is enabled.

Please take a look at these issues:

electron/electron#17523
electron/electron#31705

I've tested the library with electron 15x version and everything worked.

I'll proceed testing with all versions (from 15 to latest) and discover since when this bug is present.

@ranulrandombage
Copy link

Hi @aldoanizio,

Were you able to find a fix for this issue, I urgently need to find a solution for this, if not I might have to move to a different library :(

I tried upgrading electron v25.3.1 where they've mentioned that silent printing was fixed but the issue persists.

@aldoanizio
Copy link

aldoanizio commented Apr 23, 2024

Hi @ranulrandombage I had to downgrade Electron to 15x version and everything worked!

To be more specific I'm using Electron v15.5.7. As you are using a newer version of Electron if you choose to downgrade be aware you have to change the function to catch the printers list.

In electron newer versions when you invoke the printers list function you receive a promise. In 15x version the function will return the printers list as an array of objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants