Printing label from Node-Red Flow

Hi Everyone,

I found this post and it's exactly what I'm looking to do(print labels from Node-Red Flow):

@Steve-Mcl and @madmax were discussing generating labels with QR codes from a flow. I modified it slightly and am now generating the PDF file necessary for my application. However it was never discussed how this PDF was being printed out on the label printer. @madmax can provide more information on how you actually printed out the label? Also what label printer did you use?

Thank you,
Travis

Hi!

I use the one Zebra GK420d.

I print it directly from lp linux.

Here's an example
msg.druck = "lp -d Zebra_Etiketten_duckerpi -o media=94x264 "+msg.filename;
return msg;

What kind of system are you? raspberry pi? mac?

1 Like

Hi @madmax,

Thank you so much for replying!

I'll be running Node-Red on a Mac. I'm open to label printers so I'll take a look at the Zebra GK420d.

What are you sending that object to? An Exec node? I have never worked with a printer from software so this is new territory for me.

Just looked at the printer. I was hoping for a cut tape printer and not thermal. These labels will be placed on devices we ship to customers so they need to be a bit more "rugged". I'll see if I can find an IP addressable cut tape printer that might be suitable.

Something like this would be ideal.

The p-touch models can usually be operated from node.

E.g...

If not, there seems to be a CLI you could call from an exec node.

1 Like

Hi @Steve-Mcl,

Thank you very much for chiming in. Much appreciated.

Yes, I was looking at the node-ptouch package(had done a p-touch nodejs search). The example just shows text but this must be using raster commands to send data to the printer I assume. Brother has some convoluted documentation on it here. Comparing the constants.js file in the NodeJS library to the commands in Brother's docs don't 100% line up but they're close which give me hope.

I think I can covert the PDF to a Raster, and then feed it to the printer over a socket. I'm about 99% this will work.

I can't do much at this point as I don't have a P Touch printer. Considering ordering one. Just tough to do if I'm not certain it will work.

Thoughts?

The PDF comes after the barcode creation which is already a raster image. Just ditch the PDF part. I never understood why the op of the other thread needed that.

1 Like

Got it. So is Base64 a raster image? Sorry, I've worked with Base64 displaying images on small embedded devices, but this is my first encounter with Rasters.

@Steve-Mcl,

I'd like to start by thanking you for your time thus far. I know this is getting outside the scope of this forum but I will convert my development to an NPM library and also create a Node for Node-Red if I can get this to work in case it is of some use to others in the future.

Update on this project.

I have a Brother P950NW here I am working with now.

Unfortunately the off the shelf P Touch NPM libraries are of little to no use as they are either not compatible or not even complete.

My current work flow is using Brother's P Touch Editor software to send print files over the network connection, I then use WireShark to sniff the data being sent over the TCP socket on port 9100. Through this I have been able to determine the control commands being sent:

// 300 00 bytes Invalidate
// 1b 69 61 01 Switch to Raster Mode
// 1b 40 Initialize
// 1b 69 7a c4 00 18 00 c9 02 00 00 02 00 Print information Command
// 1b 69 4b 08 Cut Mode
// 1b 69 4d 40 Enable Cut Mode
// 1b 69 41 01 Auto Cut Every Sheet
// 1b 69 6b 63 01 00 Unknown
// 1b 69 64 Margin
// ...image bytes
// 1b 69 61 ff Unknown, runs at end.  Assume exits raster mode.

I determined what the commands are by referencing this Brother documentation.

Now sniffing the packets sent by the P Touch utility the buffer arrays are quite large and look to be Binary Bitmap buffers which matches up to the Brother Documentation. A print request that contains just a QR code and some text similar to what is generated in the Node-Red flow comes out to a payload size of 35848 bytes. Conversely if I output a Buffer object from the Base64 node in the flow it is only around 890 bytes. So this is a red flag.

I did try writing the commands and image file buffer array generated by the base64 image node but it just prints a really long blank label.

I believe what needs to be done is to covert the Base64 image buffer object to a BMP(bit map) array, this however is my first encounter with this stuff so hoping someone can provide some insight.

No, base64 is a string version of something (in this case, an image)

What you likely need is the bitmap data.

This can be easily achieved by returning a jimp image from an image node then accessing msg.payload.bitmap.data (I think/off top of head, use a debug to see)

1 Like

@Steve-Mcl,

Ok that's getting somewhere. That generated 40kb of data.

Now it seems to be an array of 0x00 and 0xFF bytes. I assume these are just on/off bits for the dot matrix.

In contrast the array sent out by the P-Touch editor software is not just an array of 0x00/0xFF bytes. Here is just a portion of the image file sent by the P-Touch Software:

1b 40 1b 69 7a c4 00 18 00 ae 00 00 00 02 00 1b
69 4b 08 1b 69 4d 40 1b 69 41 01 1b 69 6b 63 01
00 1b 69 64 0e 00 4d 02 47 02 00 bb 00 47 02 00
bb 00 47 02 00 bb 00 47 02 00 bb 00 47 02 00 bb
00 47 02 00 bb 00 47 02 00 bb 00 47 02 00 bb 00
47 02 00 bb 00 47 02 00 bb 00 47 02 00 bb 00 47
02 00 bb 00 47 02 00 bb 00 47 02 00 bb 00 47 02
00 bb 00 47 02 00 bb 00 47 02 00 bb 00 47 08 00
e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00 1f ff
ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00 47 08
00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00 1f
ff ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00 47
08 00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00
1f ff ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00
47 08 00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00
00 1f ff ff d7 00 47 08 00 e8 00 00 1f ff ff d7
00 47 08 00 e8 00 00 1f ff ff d7 00 47 08 00 e8
00 00 1f ff ff d7 00 47 08 00 e8 00 00 1f ff ff
d7 00 47 08 00 e8 00 00 1f ff ff d7 00 47 08 00
e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00 1f ff
ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00 47 08
00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00 1f
ff ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00 47
08 00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00
1f ff ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00
47 08 00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00
00 1f ff ff d7 00 47 08 00 e8 00 00 1f ff ff d7
00 47 08 00 e8 00 00 1f ff ff d7 00 47 08 00 e8
00 00 1f ff ff d7 00 47 08 00 e8 00 00 1f ff ff
d7 00 47 08 00 e8 00 00 1f ff ff d7 00 47 08 00
e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00 1f ff
ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00 47 08
00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00 1f
ff ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00 47
08 00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00
1f ff ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00
47 08 00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00
00 1f ff ff d7 00 47 08 00 e8 00 00 1f ff ff d7
00 47 08 00 e8 00 00 1f ff ff d7 00 47 08 00 e8
00 00 1f ff ff d7 00 47 08 00 e8 00 00 1f ff ff
d7 00 47 08 00 e8 00 00 1f ff ff d7 00 47 08 00
e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00 1f ff
ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00 47 08
00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00 1f
ff ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00 47
08 00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00
1f ff ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00
47 08 00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00
00 1f ff ff d7 00 47 08 00 e8 00 00 1f eb ff eb
00 47 08 00 e8 00 00 1f eb ff eb 00 47 08 00 e8
00 00 1f eb ff eb 00 47 08 00 e8 00 00 1f eb ff
eb 00 47 08 00 e8 00 00 1f eb ff eb 00 47 08 00
e8 00 00 1f eb ff eb 00 47 08 00 e8 00 00 1f eb
ff eb 00 47 08 00 e8 00 00 1f eb ff eb 00 47 08
00 e8 00 00 1f eb ff eb 00 47 08 00 e8 00 00 1f
eb ff eb 00 47 08 00 e8 00 00 1f eb ff eb 00 47
08 00 e8 00 00 1f eb ff eb 00 47 08 00 e8 00 00
1f eb ff eb 00 47 08 00 e8 00 00 1f eb ff eb 00
47 08 00 e8 00 00 1f eb ff eb 00 47 08 00 e8 00
00 1f eb ff eb 00 47 08 00 e8 00 00 1f eb ff eb
00 47 08 00 e8 00 00 1f eb ff eb 00 47 08 00 e8
00 00 1f eb ff eb 00 47 08 00 e8 00 00 1f eb ff
eb 00 47 08 00 e8 00 00 1f eb ff eb 00 47 08 00
e8 00 00 1f eb ff eb 00 47 08 00 e8 00 00 1f eb
ff eb 00 47 08 00 e8 00 00 1f ff ff d7 00 47 08
00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00 1f
ff ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00 47
08 00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00
1f ff ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00
47 08 00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00
00 1f ff ff d7 00 47 08 00 e8 00 00 1f ff ff d7
00 47 08 00 e8 00 00 1f ff ff d7 00 47 08 00 e8
00 00 1f ff ff d7 00 47 08 00 e8 00 00 1f ff ff
d7 00 47 08 00 e8 00 00 1f ff ff d7 00 47 08 00
e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00 1f ff
ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00 47 08
00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00 1f
ff ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00 47
08 00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00
1f ff ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00
47 08 00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00
00 1f ff ff d7 00 47 08 00 e8 00 00 1f ff ff d7
00 47 08 00 e8 00 00 1f ff ff d7 00 47 08 00 e8
00 00 1f ff ff d7 00 47 08 00 e8 00 00 1f ff ff
d7 00 47 08 00 e8 00 00 1f ff ff d7 00 47 08 00
e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00 1f ff
 ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00 47 08
00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00 1f
ff ff d7 00 47 08 00 e8 00 00 1f ff ff d7 00 47
08 00 e8 00 00 1f ff ff d7 00 47 08 00 e8 00 00
1f ff ff d7 00 47 08 00

There appears to be more information in this array than just on/off bits.

Still Digging.

There is definitely a reoccurring pattern here:

0e 00 4d 02 47 
02 00 bb 00 47 
02 00 bb 00 47 
02 00 bb 00 47 
02 00 bb 00 47 
02 00 bb 00 47 
02 00 bb 00 47 
02 00 bb 00 47 
02 00 bb 00 47 
02 00 bb 00 47 
02 00 bb 00 47 
02 00 bb 00 47
02 00 bb 00 47 
02 00 bb 00 47 
02 00 bb 00 47 
02 00 bb 00 47 
02 00 bb 00 47 
02 00 bb 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 
08 00 e8 00 00 1f ff ff d7 00 47 

I might be getting too deep in the weeds here. God I hate printers.