# Create a PDF with Node-Red and JSON

**URL:** <https://discourse.nodered.org/t/create-a-pdf-with-node-red-and-json/63975>\
**Category:** General\
**Created:** [15 June 2022 13:18 UTC](https://discourse.nodered.org/t/create-a-pdf-with-node-red-and-json/63975 "2022-06-15T13:18:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mauri](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@Mauri](https://discourse.nodered.org/u/Mauri)\
**Post date:** [15 June 2022 13:18 UTC](https://discourse.nodered.org/t/create-a-pdf-with-node-red-and-json/63975/1 "2022-06-15T13:18:25Z")

</div>

Hello everyone  
I want to generate a pdf-file in Node-Red and use "node-red-contrib-pdfmake".  
With the inject node I enter a json "content". Now my question, how do I create a layout in this file and can I add more text that is not in json format?  
Below how I do this.

 ![2022-06-15 15_17_41-Node-RED – Opera](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/2/125009a1abab9ef1601a3cbae8ceee2de212a2fe.png)

In addition, I cannot open the pfd file as long as node-red is running. What could be the reason for this?

Thanks for your help. Kind regards Mauri

---

<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:** [15 June 2022 13:21 UTC](https://discourse.nodered.org/t/create-a-pdf-with-node-red-and-json/63975/2 "2022-06-15T13:21:49Z")

</div>

Hi & welcome to the forum.

> [@Mauri](#):
>
> Now my question, how do I create a layout in this file and can I add more text that is not in json format?

Yes. Check out the built in example (CTRL-I --\> examples --\> PDFMAKE)

Also, search the forum (there was a PDFMAKE thread only this week that will give you clues on how to generate sections)

> [@Mauri](#):
>
> In addition, I cannot open the pfd file as long as node-red is running. What could be the reason for this?

Because using a fixed file name keeps the file open (for later additions)

In simple terms, dont specify a fixed file name, instead, pass the filename in via `msg.filename` as is explained in the file node built in help.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [15 June 2022 13:22 UTC](https://discourse.nodered.org/t/create-a-pdf-with-node-red-and-json/63975/3 "2022-06-15T13:22:38Z")

</div>

Have a look at this thread and the link to some examples.

> [@How to push multiple array pdfmake](https://discourse.nodered.org/t/how-to-push-multiple-array-pdfmake/63839/30):
>
> @Steve-Mcl @dynamicdave Thank you so much that is work fine for me.

---

<div class="post-metadata">

**Author:** ![Mauri](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@Mauri](https://discourse.nodered.org/u/Mauri)\
**Post date:** [15 June 2022 13:42 UTC](https://discourse.nodered.org/t/create-a-pdf-with-node-red-and-json/63975/4 "2022-06-15T13:42:45Z")

</div>

Thanks for your fast answers!

> [@Steve-Mcl](#):
>
> Also, search the forum (there was a PDFMAKE thread only this week that will give you clues on how to generate sections)

Can you link the thread please? I can't find it

---

<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:** [15 June 2022 13:44 UTC](https://discourse.nodered.org/t/create-a-pdf-with-node-red-and-json/63975/5 "2022-06-15T13:44:49Z")

</div>

> [@Mauri](#):
>
> link the thread please? I can't find it

👆 Look up 👆

😉

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

---

<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:** [15 June 2022 13:46 UTC](https://discourse.nodered.org/t/create-a-pdf-with-node-red-and-json/63975/6 "2022-06-15T13:46:36Z")

</div>

Try [this entry in particular](https://discourse.nodered.org/t/how-to-push-multiple-array-pdfmake/63839/20) from that thread

It demonstrates a few techniques - in particular adding text dynamically to the PDF document definition

---

<div class="post-metadata">

**Author:** ![Mauri](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@Mauri](https://discourse.nodered.org/u/Mauri)\
**Post date:** [15 June 2022 13:46 UTC](https://discourse.nodered.org/t/create-a-pdf-with-node-red-and-json/63975/7 "2022-06-15T13:46:36Z")

</div>

🤦🏾‍♂️ 🙈

Thanks a lot! 🙏🏾

---

<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:** [14 August 2022 13:47 UTC](https://discourse.nodered.org/t/create-a-pdf-with-node-red-and-json/63975/8 "2022-08-14T13:47:19Z")

</div>

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