【发布时间】: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-printer或electron-printer进行设置?
-
是的,就像我使用 node-thermal-printer 一样。
-
在node-thermal-printer的描述中,好像需要在
let printer = new ThermalPrinter的定义中指定driver:或者另外做setPrinterDriver(),所以请加一下试试它。
标签: node.js usb printers thermal-printer