如何使用节点热敏打印机连接到ZPL打印机?

时间:2018-06-16 17:53:49

标签: javascript node.js printing node-modules thermal-printer

我尝试使用 node-thermal-printer https://github.com/Klemen1337/node-thermal-printer/)与 ZPL打印机https://chrome.google.com/webstore/detail/zpl-printer/phoidlklenidapnijkabnfdgmadlcmjo)建立联系。

当我运行ZPL打印机时,我可以通过以下地址中的URL浏览器成功访问打印机:(http://localhost:9100/

我使用 node-thermal-printer 连接打印机的Javascript代码是:

printer.init({
      type: "epson",                    
      interface: "/dev/usb/lp0",       // Linux interface
      ip: "localhost",                // Ethernet printing IP
      port: "9100"                   // Ethernet printing PORT
});

printer.isPrinterConnected( function(isConnected){ 
    console.log(isConnected);
}); 

运行这个,我有一个错误的连接。

在IP地址中,我也尝试过:http://127.0.0.1/和端口:9100,但它不起作用。

请有人帮助我。

抱歉我的英语不好。

1 个答案:

答案 0 :(得分:0)

如果您的打印机是网络打印机,请尝试以下操作:

printer.init({
  type: 'epson',
  interface: 'tcp://yourip:9100',

});

用您的打印机IP替换您的IP

相关问题