Nodejs如何向QL-720NW发送P-Touch Template指令

How Nodejs Send P-Touch Template Command to QL-720NW

我只是用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);}
});

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

终于找到核心问题了

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

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

第三,发送命令如下

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

你可以打印它。

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

祝你好运。