相关疑难解决方法(0)

无法使用节点js ipp模块进行打印

我有一个pritter通过USB端口连接到我的电脑.我运行Windows 7.

这是简单的代码:

var ipp=require('ipp')
var fs = require('fs');

fs.readFile('filename.pdf', function(err, data) { 
  if (err)
    throw err;

  var printer = ipp.Printer("http://localhost/ipp/printer");
  var msg = {
    "operation-attributes-tag": {
      "requesting-user-name": "William",
      "job-name": "My Test Job",
      "document-format": "application/pdf"
    },
    data: data
  };
  printer.execute("Print-Job", msg, function(err, res){
    if(err){
        console.log(err);
    }
    console.log(res);
  });
});
Run Code Online (Sandbox Code Playgroud)

我如何解决我的本地priter地址写在这里:

var printer = ipp.Printer("http://localhost/ipp/printer");
Run Code Online (Sandbox Code Playgroud)

node.js

4
推荐指数
1
解决办法
1893
查看次数

节点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();
Run Code Online (Sandbox Code Playgroud)

usb thermal-printer printers node.js

4
推荐指数
1
解决办法
4005
查看次数

标签 统计

node.js ×2

printers ×1

thermal-printer ×1

usb ×1