# Print using CUPS

**URL:** <https://discourse.nodered.org/t/print-using-cups/78943>\
**Category:** General\
**Tags:** node-red-dashboard, function-node\
**Created:** [5 June 2023 03:25 UTC](https://discourse.nodered.org/t/print-using-cups/78943 "2023-06-05T03:25:26Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jhontan14](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@Jhontan14](https://discourse.nodered.org/u/Jhontan14)\
**Post date:** [5 June 2023 03:25 UTC](https://discourse.nodered.org/t/print-using-cups/78943/1 "2023-06-05T03:25:26Z")

</div>

Hello, I have a ZD30 printer installed in IoT 2050 gateway using CUPS, I want to know if there is any way to send to print from node-RED?

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [5 June 2023 04:32 UTC](https://discourse.nodered.org/t/print-using-cups/78943/2 "2023-06-05T04:32:55Z")

</div>

Hi.

My colleague used the [node-red-contrib-ipprint - npm](https://www.npmjs.com/package/node-red-contrib-ipprint) node for that.  
We're sending a Buffer containing a PDF there, has been working fine so far.

The CUPS printer must have the "Share" flag enabled, otherwise it won't work.

I hope this will help you to get started.

---

<div class="post-metadata">

**Author:** ![Jhontan14](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@Jhontan14](https://discourse.nodered.org/u/Jhontan14)\
**Post date:** [5 June 2023 17:25 UTC](https://discourse.nodered.org/t/print-using-cups/78943/3 "2023-06-05T17:25:29Z")

</div>

```auto
[{"id":"74ac8e787b168218","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"eeec9e7369b5ead6","type":"http request","z":"74ac8e787b168218","name":"","method":"PUT","ret":"bin","paytoqs":"ignore","url":"https://us-central1-faneamiento-app.cloudfunctions.net/animalsapp/animals","tls":"","persist":false,"proxy":"","authType":"","x":150,"y":120,"wires":[["426b2457e54e033b"]]},{"id":"426b2457e54e033b","type":"function","z":"74ac8e787b168218","name":"","func":"// Obtener el Binary Buffer de la imagen\nvar buffer = msg.payload;\n\n// Convertir el Binary Buffer a una URL de datos (data URL)\nvar dataUrl = 'data:image/jpeg;base64,' + buffer.toString('base64');\n\n// Enviar la URL de datos en el mensaje\nmsg.payload = dataUrl;\n\n// Devolver el mensaje para pasar al siguiente nodo\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":120,"wires":[["c7695bb55b6e5143"]]},{"id":"c7695bb55b6e5143","type":"ui_template","z":"74ac8e787b168218","group":"96f57673356c6885","name":"","order":1,"width":"6","height":"4","format":"<img src=\"{{msg.payload}}\" alt=\"Imagen\">","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":600,"y":120,"wires":[[]]},{"id":"96f57673356c6885","type":"ui_group","name":"Etiqueta","tab":"4cebec0ed5def0cf","order":3,"disp":true,"width":"6","collapse":false},{"id":"4cebec0ed5def0cf","type":"ui_tab","name":"Ganado Porcino","icon":"input","disabled":false,"hidden":false}]

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/3/d3786c040d3f4839ccceddbd0034a5975a91f91f.png)  
This is my flow, I send certain characters and the http request node returns an image to me, I want to send this image to print to a printer configured in CUPS

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [5 June 2023 19:03 UTC](https://discourse.nodered.org/t/print-using-cups/78943/4 "2023-06-05T19:03:21Z")

</div>

Did you install the node (as was suggested) and try anything with it?

---

<div class="post-metadata">

**Author:** ![Jhontan14](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@Jhontan14](https://discourse.nodered.org/u/Jhontan14)\
**Post date:** [5 June 2023 19:29 UTC](https://discourse.nodered.org/t/print-using-cups/78943/5 "2023-06-05T19:29:21Z")

</div>

Yes, I installed it as it says in the manual, but the node does not appear in the manage palette

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [5 June 2023 23:55 UTC](https://discourse.nodered.org/t/print-using-cups/78943/6 "2023-06-05T23:55:07Z")

</div>

1. What device are you running NR on and what OS?
2. What version of NR and node.js? (you can find this in the NR startup log)
3. When you did the install were you in the .node-red folder? If not, go to a terminal window and change folders so you are in the .node-red folder. Then run the

```auto
npm i node-red-contrib-ipprint

```

command. Once that is done, stop and restart NR. At that pointy should see it in the pallet and in the left menu.

 ![Screenshot 2023-06-05 at 7.54.40 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/3/330091bca16166365eecfb0e9d6f806e5f5bae11.png)

---

<div class="post-metadata">

**Author:** ![Jhontan14](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@Jhontan14](https://discourse.nodered.org/u/Jhontan14)\
**Post date:** [10 June 2023 18:04 UTC](https://discourse.nodered.org/t/print-using-cups/78943/7 "2023-06-10T18:04:34Z")

</div>

I was finally able to install node.  
At the end of all the code there is an "http request" node, which returns me an image and with the "function" node I present it in an html template.  
Could you help me to print the image to a printer at a certain IP address?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/4/14ebffdf92e4e23f73a6188a52ca3363c4f19c7c.png)

```auto
[{"id":"e9c7705cf137b29e","type":"tab","label":"cerdos","disabled":false,"info":""},{"id":"f18df0fae51a6344","type":"ui_form","z":"e9c7705cf137b29e","name":"","label":"","group":"dff1b7f895ec7f67","order":1,"width":6,"height":2,"options":[{"label":"Peso Total","value":"pesoTotal","type":"number","required":true,"rows":null},{"label":"Tipo","value":"tipo","type":"text","required":true,"rows":null},{"label":"Código","value":"id","type":"text","required":true,"rows":null}],"formValue":{"pesoTotal":"","tipo":"","id":""},"payload":"","submit":"Enviar","cancel":"Cancelar","topic":"topic","topicType":"msg","splitLayout":false,"x":510,"y":240,"wires":[["9dc07639a4695a6f"]]},{"id":"3d239101d1222b69","type":"change","z":"e9c7705cf137b29e","name":"","rules":[{"t":"set","p":"msg","pt":"flow","to":"msg.payload","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload.tipo","pt":"msg","to":"msg","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":240,"wires":[["f18df0fae51a6344"]]},{"id":"30bb0e4a8065b75f","type":"inject","z":"e9c7705cf137b29e","name":"","props":[{"p":"payload"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Porcino","payloadType":"str","x":60,"y":240,"wires":[["3d239101d1222b69"]]},{"id":"ab15538e30e120ae","type":"debug","z":"e9c7705cf137b29e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1070,"y":300,"wires":[]},{"id":"9dc07639a4695a6f","type":"function","z":"e9c7705cf137b29e","name":"","func":"let id =msg.payload.id;\nlet txt=id.toString();\ntxt = txt.slice(0, 3) + \"-\" + txt.slice(3);\nmsg.payload.id=txt\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":240,"wires":[["85c390652dfed930"]]},{"id":"b616955816d6825a","type":"change","z":"e9c7705cf137b29e","name":"","rules":[{"t":"set","p":"msg","pt":"flow","to":"msg.payload","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload.pesoDer","pt":"msg","to":"msg","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":300,"wires":[["85c390652dfed930"]]},{"id":"b291db183d83e82f","type":"inject","z":"e9c7705cf137b29e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"pesoDer","payload":"0","payloadType":"num","x":90,"y":300,"wires":[["b616955816d6825a"]]},{"id":"85c390652dfed930","type":"join","z":"e9c7705cf137b29e","name":"","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":630,"y":360,"wires":[["ba7195db95470a0a"]]},{"id":"ea0ead19afd87fc2","type":"serial in","z":"e9c7705cf137b29e","name":"","serial":"9d10fcb604e753dd","x":70,"y":80,"wires":[[]]},{"id":"5acb4b9787b0fc8e","type":"change","z":"e9c7705cf137b29e","name":"","rules":[{"t":"set","p":"msg","pt":"flow","to":"msg.payload","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload.pesoTotal","pt":"msg","to":"msg","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":80,"wires":[["6aaa8e683e703fe8"]]},{"id":"6aaa8e683e703fe8","type":"function","z":"e9c7705cf137b29e","name":"","func":"let str2 =msg.payload.pesoTotal;\nlet txt2=parseFloat(str2);\n\nmsg.payload.pesoTotal=txt2\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":580,"y":80,"wires":[["f18df0fae51a6344"]]},{"id":"15c0fc138073b9c4","type":"function","z":"e9c7705cf137b29e","name":"","func":"let izq=msg.payload;\nizq=izq.slice(12,17);\nmsg.payload=izq;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":240,"y":80,"wires":[["5acb4b9787b0fc8e"]]},{"id":"ba7195db95470a0a","type":"http request","z":"e9c7705cf137b29e","name":"","method":"PUT","ret":"bin","paytoqs":"ignore","url":"https://us-central1-faneamiento-app.cloudfunctions.net/animalsapp/animals","tls":"","persist":false,"proxy":"","authType":"","x":790,"y":360,"wires":[["ab15538e30e120ae","1225cc7b776f5fdc"]]},{"id":"4ee3afbf562c5a35","type":"change","z":"e9c7705cf137b29e","name":"","rules":[{"t":"set","p":"msg","pt":"flow","to":"msg.payload","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload.pesoIzq","pt":"msg","to":"msg","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":360,"wires":[["85c390652dfed930"]]},{"id":"0ee9ae452c1b51cd","type":"inject","z":"e9c7705cf137b29e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"pesoIzq","payload":"0","payloadType":"num","x":90,"y":360,"wires":[["4ee3afbf562c5a35"]]},{"id":"be474c3f4455ac47","type":"inject","z":"e9c7705cf137b29e","name":"","props":[{"p":"payload"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"ST,NT,5 25 kg","payloadType":"str","x":80,"y":20,"wires":[[]]},{"id":"1225cc7b776f5fdc","type":"function","z":"e9c7705cf137b29e","name":"","func":"// Obtener el Binary Buffer de la imagen\nvar buffer = msg.payload;\n\n// Convertir el Binary Buffer a una URL de datos (data URL)\nvar dataUrl = 'data:image/jpeg;base64,' + buffer.toString('base64');\n\n// Enviar la URL de datos en el mensaje\nmsg.payload = dataUrl;\n\n// Devolver el mensaje para pasar al siguiente nodo\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":980,"y":460,"wires":[["955771dfdfbeaa49","51e5fdb12980c809"]]},{"id":"955771dfdfbeaa49","type":"ui_template","z":"e9c7705cf137b29e","group":"96f57673356c6885","name":"","order":1,"width":"6","height":"4","format":"<img src=\"{{msg.payload}}\" alt=\"Imagen\">","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":1140,"y":460,"wires":[[]]},{"id":"51e5fdb12980c809","type":"IPPrint","z":"e9c7705cf137b29e","name":"Zebra","IP":"192.168.0.17","JOB_name":"","authuser":"","authpassword":"","authcheck":"","x":1110,"y":540,"wires":[[]]},{"id":"dff1b7f895ec7f67","type":"ui_group","name":"Registro de información","tab":"4cebec0ed5def0cf","order":1,"disp":true,"width":"6","collapse":false},{"id":"9d10fcb604e753dd","type":"serial-port","serialport":"/dev/ttyUSB0","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","waitfor":"","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"\\n","bin":"false","out":"char","addchar":"","responsetimeout":"1000"},{"id":"96f57673356c6885","type":"ui_group","name":"Etiqueta","tab":"4cebec0ed5def0cf","order":3,"disp":true,"width":"6","collapse":false},{"id":"4cebec0ed5def0cf","type":"ui_tab","name":"Ganado Porcino","icon":"input","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [10 June 2023 19:30 UTC](https://discourse.nodered.org/t/print-using-cups/78943/8 "2023-06-10T19:30:03Z")

</div>

1. What device are you running NR on and what OS?
2. What version of NR and node.js? (you can find this in the NR startup log)

1. Does yhe CUPS printer have the "Share" flag enabled?

---

<div class="post-metadata">

**Author:** ![Jhontan14](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@Jhontan14](https://discourse.nodered.org/u/Jhontan14)\
**Post date:** [10 June 2023 19:44 UTC](https://discourse.nodered.org/t/print-using-cups/78943/9 "2023-06-10T19:44:35Z")

</div>

1. Gateway IoT 2050 use Debian
2. Node-RED v2.0.6 node.js v12.225
3. Yes

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [10 June 2023 20:04 UTC](https://discourse.nodered.org/t/print-using-cups/78943/10 "2023-06-10T20:04:51Z")

</div>

1. Add a `debug` node (set to display the complete msg object) to the output of the `IPPrint` node
2. Add a `catch` node connected to a `debug` node (set to display the complete msg object)

Do you get anything when you try to send a print?

Also, please run NR from the command line and look at the log after you try to print then copy and paste the log in a reply.

---

<div class="post-metadata">

**Author:** ![Jhontan14](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@Jhontan14](https://discourse.nodered.org/u/Jhontan14)\
**Post date:** [10 June 2023 21:03 UTC](https://discourse.nodered.org/t/print-using-cups/78943/11 "2023-06-10T21:03:37Z")

</div>

This is the result

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/9/19990c7c3324fddbf94ba5dcc81908848a30dc74.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [10 June 2023 21:06 UTC](https://discourse.nodered.org/t/print-using-cups/78943/12 "2023-06-10T21:06:20Z")

</div>

Two things, I asked you to

- 
  1. Add a `catch` node connected to a `debug` node (`set to display the complete msg object`)

- 
  1. run NR from the command line and look at the log after you try to print then copy and paste the log in a reply

In addition, please don't do screen prints, copy the debug information and paste it to a reply.

There’s a great page in the docs ([Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [9 August 2023 21:06 UTC](https://discourse.nodered.org/t/print-using-cups/78943/13 "2023-08-09T21:06:57Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
