Generate a PDF-file with variable filename

Hello Community

I want to generate a pdf in node red and want to enter the file name (and maybe the location) with variables. I heard that this could work with the msg.filename, but I couldn't find anything. can someone help me?

So I can generate a pdf but the file name is fixed.
Thanks for your help!

Mauri

remove the hard coded filename from the file node & in your function add something like...

// your code
const reportDate = new Date().toISOString().replace(/[TG]/g,'_').replace(/:/g,'-').substring(0,19);
const reportName = 'mydata'
msg.filename = `c/reports/report-${reportName}-${reportDate}.pdf`
return msg;

Thanks for your answer! :pray:t5:
It works! :partying_face:

How can i program if there is no data the line should not be written?

For example this line:


If there is no data from "0x_0x_we_id", then the column should not be written...

If you post code/flow instead of pictures I can show you.

PS...

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 ```)

``` 
   code goes here 
```

See this post for more details - How to share code or flow json

PS2
If you dont reply to my comment I have no idea you have replied (there are 2 reply buttons, 1 at the bottom and one on a users last comment - this one notifies the user you are replying to them)

This is my flow:
Flow_Mauri.txt (50.3 KB)

The flow is in a -txt file, 'cause it's to big to share with the ```

I hope you can understand it...
Thanks

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