节点USB打印机

问题描述

enter image description here

任何人都知道如何为 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();

解决方法

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

  1. 首先进行打印机共享 enter image description here

  2. 你修改了表示路径和共享打印机的值“interface”

    #include <iostream>
    #include <string>
    using namespace std;
    
    string topSecret(string);//prototype for topSecret function after main
    
    int main()
    {
        //Top Secret Input
        string name,social,userName,password;
        cout << "Enter your first name,Social Security number (digits only),userID (no spaces within ID),and password (no spaces within password) - with a space between each entry: ";
        cin >> name >> social >> userName >> password;
        cout << "Name: " << name << endl;
        cout << "SSN: " << social.replace(0,social.length(),"X");
        cout << "SSN: " << social.insert(2,"-") << endl;
        cout << "UserID: " << userName << endl;
        cout << "Password: " << topSecret(password) << endl;
    
        return 0;
    }//end main
    
    string topSecret (string password)//replace all characters in password to an X
    {
        string::size_type length;
        string::size_type pw;
        for (pw = 0; pw < password.length(); pw++)//for the duration of the password
        {
        }//end for loop
    }//end topSecret
    

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...