Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node usb printer

enter image description hereAnyone knows how to set-up a USB printer for node js. I m not able to configure the interface for it . Here is my code

enter code here const ThermalPrinter = require("../node-thermal-printer").printer;
                const Types = require("../node-thermal-printer").types;
                const electron = typeof process !== 'undefined' && process.versions && 
                                  !!process.versions.electron;

                async function testConnection () { 

                let printer = new ThermalPrinter({
                type: 'star',                                    
                interface: "Gold" //name of the printer
                });
                printer.print("hi");
                let isConnected = await printer.isPrinterConnected() 
                console.log("Printer connected:", isConnected);
                }
                 testConnection();
like image 217
Rahul Mongia Avatar asked Oct 27 '25 02:10

Rahul Mongia


1 Answers

The error that jumps out at me is in your interface. if you use a usb port I advise you to start by making a print sharing and then to configure your node-termal-printer file by modifying the value "interface"

  1. first you do a printer sharing enter image description here

  2. you modify the value "interface" indicating the path and the shared printer

         `interface: '//localhost/printer',`
    
like image 162
Minute Illimitée Avatar answered Oct 28 '25 17:10

Minute Illimitée



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!