Nodejs如何将P-Touch模板命令发送到QL-720NW

时间:2016-06-10 09:23:18

标签: node.js printing escpos

我只是使用Nodejs将p-touch模板代码发送到QL-720NW。

我已经按照how to setup p-touch template步骤进行了操作。

另外,我尝试使用tojocky/node-printer向打印机发送命令。

这是我的代码,

var rawData = new Buffer([
0x1B, 0x69, 0x61, 0x33, // Use p-touch template
0x5E, 0x49, 0x49, // Initialize p-touch template
0x5E, 0x54, 0x53, 0x30, 0x30, 0x31, // Choose template 1
0x5E, 0x46, 0x46 // Start printing
]);

printer.printDirect({
     data: rawData
     , printer:'Brother QL-720NW' // printer name, if missing then will print to default printer
     , type: 'RAW' // type: RAW, TEXT, PDF, JPEG, .. depends on platform
     , success:function(jobID){
        console.log("sent to printer with ID: "+jobID);
   }
   , error:function(err){console.log(err);}
});

但是,打印机总是出现故障并闪烁红灯。 只需致电兄弟技术支持并搜索技术规范。找不到任何主意。有人有想法吗?

1 个答案:

答案 0 :(得分:3)

最后,我找到了核心问题。

首先,tojocky / node-printer可以将ESC / P发送到QL-720NW。

其次,主要问题来自p-touch模板。设计标签布局时。每个ui小部件分配的对象名称都需要注入一个值。如果你想要一个静态对象,你应该删除对象名称并勾选一个强制小部件无法修改的复选框。

第三,发送命令如下

  1. 切换到P-touch模板模式(ESC ia3)
  2. 初始化(^ ||)
  3. 选择模板(^ TS001)
  4. 选择对象名称(^ ONobject \ x0h)
  5. 直接插入数据(^​​ DI \ x05h \ x0hHello)
  6. 开始打印(^ FF)
  7. 你可以打印出来。

    示例代码: https://github.com/KingWu/NodePrinterExample

    祝你好运。