# Putting different images in a pdf, duplication error

**URL:** <https://discourse.nodered.org/t/putting-different-images-in-a-pdf-duplication-error/86768>\
**Category:** General\
**Tags:** node-red-dashboard, function-node\
**Created:** [26 March 2024 13:07 UTC](https://discourse.nodered.org/t/putting-different-images-in-a-pdf-duplication-error/86768 "2024-03-26T13:07:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erissin\_Industria4.0](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@Erissin\_Industria4.0](https://discourse.nodered.org/u/Erissin_Industria4.0)\
**Post date:** [26 March 2024 13:07 UTC](https://discourse.nodered.org/t/putting-different-images-in-a-pdf-duplication-error/86768/1 "2024-03-26T13:07:43Z")

</div>

Again I'm here with this PDF issue, I can put the images inside the PDF, but even though I put the directory of different images one always overlaps the other, I've tried several things and so far I haven't been able to solve this problem

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/5/f5ee767438cf5b27e5fa2c3a88694f834d7febb8.png)  
I believe that the crucial part is within the template node  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/1/d110c417cdf1865ad0b127fefcdc169761422dcf.png)  
specifically on this line, but I don't know how to differentiate the payloads here in a way that accepts it, whenever I try node-red dies  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/c/2c4170d2ce66150500d515e7d6bfc9b472b6bd15.png)

My flow down:

```auto
[{"id":"54ef025d.56fccc","type":"template","z":"2521f04f9179ef7d","name":"","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n \"pageSize\": \"A4\",\n \"pageOrientation\": \"portrait\",\n \"pageMargins\": [\n 40,\n 60,\n 40,\n 60\n],\n \"info\": {\n \"title\": \"awesome Document\",\n \"author\": \"john doe\",\n \"subject\": \"subject of document\",\n \"keywords\": \"keywords for document\"\n },\n \"content\": [\n {\n \"text\": \"Logo São Paulo Skills\",\n \"alignment\": \"center\",\n \"margin\": [\n 0,\n 0,\n 0,\n 20\n]\n },\n {\n \"image\": \"data:image/jpeg;base64,{{{payload}}}\",\n \"width\": 200,\n \"alignment\": \"center\",\n \"margin\": [\n 0,\n 0,\n 0,\n 20\n] \n },\n {\n \"image\": \"data:image/jpeg;base64,{{{payload}}}\",\n \"width\": 201,\n \"alignment\": \"center\"\n }\n ]\n}","output":"json","x":900,"y":300,"wires":[["bdd7feab.d9412"]]}]

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 March 2024 13:19 UTC](https://discourse.nodered.org/t/putting-different-images-in-a-pdf-duplication-error/86768/2 "2024-03-26T13:19:36Z")

</div>

> [@Erissin\_Industria4.0](#):
>
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/5/f5ee767438cf5b27e5fa2c3a88694f834d7febb8.png)

The is a basic and fundamental node-red thing you need to get to grips with - messages will NEVER arrive from 2 wires into a node at the same time. i.e. your template will see 2 messages, each with a `payload`

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/d/5d2973006804f2a938ec3fa206aa956bda1ce46e.png)

  

> [@Erissin\_Industria4.0](#):
>
> specifically on this line, but I don't know how to differentiate the payloads here in a way that accepts it, whenever I try node-red dies  
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/c/2c4170d2ce66150500d515e7d6bfc9b472b6bd15.png)

As established above, msg.payload is msg.payload. Unless you move/rename that property that is all it will ever be. So I recommend putting the file+base64 nodes in series (you have them in parallel currently) and use change nodes after the base64 nodes to move msg.payload into msg.image1 and msg.image2

`inject → file → base64 → change node (move payload to image1) → file → base64 → change node (move payload to image2) → template`

Add a debug node BEFORE the template to check you have msg.image1 and msg.image2 in a single `msg` entering the template, then you can use `{{{image1}}}` and `{{{image2}}}`

---

<div class="post-metadata">

**Author:** ![Erissin\_Industria4.0](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@Erissin\_Industria4.0](https://discourse.nodered.org/u/Erissin_Industria4.0)\
**Post date:** [26 March 2024 14:36 UTC](https://discourse.nodered.org/t/putting-different-images-in-a-pdf-duplication-error/86768/3 "2024-03-26T14:36:12Z")

</div>

Thank you for the answer, I did what you recommended but the value appears as "undefined" in the debug, I tried it in parallel by joining with a join but it didn't work either

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/f/4f376ce96fadcea872953f30d9e7893946394f48.png)  
I did this for both  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/9/8923a8b97daea339aae8eaaf5a3630187763bddd.png)  
It seems that the payload is lost when converting the payload

The series way as you said didn't work either

---

<div class="post-metadata">

**Author:** ![Erissin\_Industria4.0](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@Erissin\_Industria4.0](https://discourse.nodered.org/u/Erissin_Industria4.0)\
**Post date:** [26 March 2024 14:40 UTC](https://discourse.nodered.org/t/putting-different-images-in-a-pdf-duplication-error/86768/4 "2024-03-26T14:40:45Z")

</div>

Now I did it, I replaced the changes with two functions, and it worked, thank you very much for your help, another question, do you know how I could put a text object with the value of the current time at which the pdf was generated in the pdf??

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 March 2024 14:41 UTC](https://discourse.nodered.org/t/putting-different-images-in-a-pdf-duplication-error/86768/5 "2024-03-26T14:41:37Z")

</div>

> [@Erissin\_Industria4.0](#):
>
> Thank you for the answer, I did what you recommended

No, you have missed the point I'm afraid.

Read this again...

> [@Steve-Mcl](#):
>
> The is a basic and fundamental node-red thing you need to get to grips with - messages will NEVER arrive from 2 wires into a node at the same time. i.e. your template will see 2 messages, each with a `payload`
> 
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/d/5d2973006804f2a938ec3fa206aa956bda1ce46e.png)

  

This is in series...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/f/bf8b28b0987be93fd03452e21f2d457151e80fbe.png)

  

Also, please try to do as recommended:

> [@Steve-Mcl](#):
>
> Add a debug node BEFORE the template to check you have msg.image1 and msg.image2 in a single `msg` entering the template

* * *

EDIT

PS:  
Your join version _could_ work if you set it up correctly (i.e. added topics and joined to a key/value pair)

---

<div class="post-metadata">

**Author:** ![Erissin\_Industria4.0](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@Erissin\_Industria4.0](https://discourse.nodered.org/u/Erissin_Industria4.0)\
**Post date:** [26 March 2024 14:45 UTC](https://discourse.nodered.org/t/putting-different-images-in-a-pdf-duplication-error/86768/6 "2024-03-26T14:45:41Z")

</div>

@Steve-Mcl

---

<div class="post-metadata">

**Author:** ![Erissin\_Industria4.0](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@Erissin\_Industria4.0](https://discourse.nodered.org/u/Erissin_Industria4.0)\
**Post date:** [27 March 2024 18:06 UTC](https://discourse.nodered.org/t/putting-different-images-in-a-pdf-duplication-error/86768/7 "2024-03-27T18:06:56Z")

</div>

I'm not able to put the datetime value in the pdf yet, I even have an idea of ​​how to put the value of my input into the pdf, I just don't know what the code would look like inside the template, because when I try to put a var inside it I get an error , does not accept

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [27 March 2024 19:25 UTC](https://discourse.nodered.org/t/putting-different-images-in-a-pdf-duplication-error/86768/8 "2024-03-27T19:25:36Z")

</div>

Exactly the same as the images. Get a time string into the msg (the same msg that the images are in) in any property you wish to invent (e.g. msg.datetime) then use the curly brackets as before. "Generated: {{{datetime}}}"

---

<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:** [10 April 2024 19:26 UTC](https://discourse.nodered.org/t/putting-different-images-in-a-pdf-duplication-error/86768/9 "2024-04-10T19:26:30Z")

</div>

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