首页 > 解决方案 > 节点usb打印机

问题描述

在此处输入图像描述任何人都知道如何为 node js 设置 USB 打印机。我无法为其配置接口。这是我的代码

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();

标签: node.jsusbprintersthermal-printer

解决方案


跳出我的错误在您的界面中。如果您使用 USB 端口,我建议您首先进行打印共享,然后通过修改值“interface”来配置您的 node-termal-printer 文件

  1. 首先你做一个打印机共享 在此处输入图像描述

  2. 您修改指示路径和共享打印机的值“interface”

         `interface: '//localhost/printer',`
    

推荐阅读