KingWu KingWu - 1 year ago 151
Node.js Question

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

I just use Nodejs to send p-touch template code to QL-720NW.

i already followed the steps how to setup p-touch template.

Also, i try to use tojocky/node-printer to send commands to printer.

Here is my code,

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

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);}

But, the printer always get fail and flash in red light.
Just call brother technical support and search technical spec. Cannot find any idea. Anyone have idea?

Answer Source

Finally, i found the core issue.

First, tojocky/node-printer can work with sending ESC/P to QL-720NW.

Secondly, the main issue is came from p-touch template. When you design the label layout. Each ui widget assigned Object name is required to inject a value. If you want a static object, you should remove Object name and tick a checkbox which force the widget cannot modify.

Thirdly, send a commands as follow

  1. Switch to P-touch template Mode (ESC ia3)
  2. Initialize (^||)
  3. Choose template (^TS001)
  4. Select Object Name (^ONobject\x0h)
  5. Directly insert data (^DI\x05h\x0hHello)
  6. Start printing (^FF)

you can print it.

Sample Code:

Good luck.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download