Open abhishek73magar opened 1 year ago
window.navigator.serial
and window.navigator.usb
are both in experimental and are not supported by all browsers, in fact it is only supported in the latest versions of chrome, edge and opera.
I am also facing this issues and still looking for a better way that is cross browser to connect to thermal printer that are attached through USB.
@seokju-na any suggestions pleas.
Since react-thermal-printer
library focus rendering the content marked up with JSX as data that can be printed on a thermal printer, but not responsible for the interface sending data to the thermal printer.
This library won't solve connecting to the printer, but i can give some guide.
In Web Browser:
In Electron or Node.js:
window.navigator.serial
andwindow.navigator.usb
are both in experimental and are not supported by all browsers, in fact it is only supported in the latest versions of chrome, edge and opera.I am also facing this issues and still looking for a better way that is cross browser to connect to thermal printer that are attached through USB.
@seokju-na any suggestions pleas.
Have you found a solution? I'm facing the same problem with a thermal printer attached via USB and not serial. The WebUSB API could help but it's a bit intricate to work, so using the library with USB would be great but unfortunately, I'm missing the serial port on my PC so I can't use it as of now.
I found this: https://github.com/drffej/webusb.printer
It's a very simple snippet that actually works and lets you print some text on a USB-attached printer (just adjust the vendorId
filter to your case). You can take the code as an example and print your own stuff.
Also, if you see an error "Failed to execute 'open' on 'USBDevice': Access denied."
install this "Zadig" as explained here: https://stackoverflow.com/a/76488056/19193089
You won't have any cool looking Components like this library offers, you'll have to format your own string and feed it to the encoder, but it should work.
Unable to connect and print the text using usb cable and also get error :
DOMException: Failed to execute 'open' on 'SerialPort': Failed to open serial port. : (this in chrome)
TypeError: Cannot read properties of undefined (reading 'requestPort') at handle (App.js:20:1) : (this in brave browser)
is it automatic connect to the printer or somthing else can you tellme how should i fixed it