节点USB打印机 [英] Node usb printer

查看:44
本文介绍了节点USB打印机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道如何为 node js 设置 USB 打印机.我无法为其配置接口.这是我的代码

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

推荐答案

我跳出的错误是在你的界面上.如果您使用 USB 端口,我建议您首先进行打印共享,然后通过修改值interface"来配置您的节点终端打印机文件

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. 首先进行打印机共享

  1. first you do a printer sharing

您修改值interface";指明路径和共享打印机

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

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

这篇关于节点USB打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆