【问题标题】:Node usb printer节点usb打印机
【发布时间】:2021-02-02 05:50:06
【问题描述】:

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

【问题讨论】:

  • 根据npm描述文章,interface: "Gold"写成interface: "printer:Gold"不是吗? Interface options
  • 设置后表示无法找到为其设置的驱动程序。即使我尝试将界面设置为“打印机:黄金”仍然卡在驱动程序集中
  • 同解释,是否需要使用node-printerelectron-printer进行设置?
  • 是的,就像我使用 node-thermal-printer 一样。
  • 在node-thermal-printer的描述中,好像需要在let printer = new ThermalPrinter的定义中指定driver:或者另外做setPrinterDriver(),所以请加一下试试它。

标签: node.js usb printers thermal-printer


【解决方案1】:

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

  1. 首先你做一个打印机共享

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-07
    • 2016-12-01
    • 2021-09-27
    相关资源
    最近更新 更多