Printer Configuration in Node-Red

Hello everyone,

I'm currently working on designing a label for a dashboard, and I need this label to be printed via a printer when a command is triggered. The printer will either be installed locally on a Windows machine or accessible over the network.

As I'm new to Node-RED, I would really appreciate some guidance on how to get started and what the overall flow should look like. Any help or suggestions would be greatly appreciated.

Thank you in advance!

Hello, and welcome to Node-RED and to the forum.

I’m reading this forum since many years and never have read anything close to what you plan to achieve. There is most probably no ready made solution. Building blocks might be:

  • create a PDF file with the content
  • send it to a client which handles the Internet Printing Protocol connected to the printer

Kind regards, Urs.

1 Like

You can use the window.print() function from within a template node. Just create a popup window, populate it with whatever you wish to print, and then send it to the printer. For example:

<template>
    <div>
        <v-btn @click="goPrint('<h1>Hello World!</h1>')">Print Hello</v-btn>
    </div>
</template>
<script>
    export default {
        methods: {
            goPrint: function (text) {
              const htmlPrefix = '<html><head><title>Print</title></head><body>';
              const htmlSuffix = '</body></html>';
              const printWindow = window.open('', '', 'width=800,height=600');
              printWindow.document.write(htmlPrefix);
              printWindow.document.write(text);
              printWindow.document.write(htmlSuffix);
              printWindow.document.close();

              printWindow.focus();
              printWindow.print();
              printWindow.close();
            }
        }
    }
</script>
2 Likes

Been here.. Done this

I would recommend Zebra printers using ZPL or Epson

Its all Text based, You can do an online design Labelary Online ZPL Viewer

grab the ascii text, put your variables into a function node and send to the printer with TCP port 9100

Done

1 Like