# Downloading pdf file from internet

**URL:** <https://discourse.nodered.org/t/downloading-pdf-file-from-internet/54324>\
**Category:** General\
**Tags:** http-request, security\
**Created:** [26 November 2021 10:23 UTC](https://discourse.nodered.org/t/downloading-pdf-file-from-internet/54324 "2021-11-26T10:23:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [26 November 2021 10:23 UTC](https://discourse.nodered.org/t/downloading-pdf-file-from-internet/54324/1 "2021-11-26T10:23:11Z")

</div>

Maybe anyone can help me with this problem.  
I am trying to download a pdf file from a web address and store it on RPI. THis file is not secured, I think. I can normally download it my self from the web. But If I download the file, it seems it is empty.  
I am confused. Here is the flow.

```auto
[{"id":"85a8308c80750364","type":"http request","z":"70e5f74f5e9b1992","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://www.lampiris.be/sites/default/files/pricesgrids/current/tarif_tip_elec_fla_nl_-_resi.pdf","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":520,"y":1540,"wires":[["eecd1c36ce19a5da"]]},{"id":"f7f56ac39d0a067e","type":"inject","z":"70e5f74f5e9b1992","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":340,"y":1540,"wires":[["85a8308c80750364"]]},{"id":"f37ad39bdf1d2694","type":"debug","z":"70e5f74f5e9b1992","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":930,"y":1480,"wires":[]},{"id":"3c3e0504195ec439","type":"file","z":"70e5f74f5e9b1992","name":"Lampiris file","filename":"","appendNewline":false,"createDir":true,"overwriteFile":"true","x":870,"y":1540,"wires":[[]]},{"id":"eecd1c36ce19a5da","type":"function","z":"70e5f74f5e9b1992","name":"","func":"let folder = global.get('file.lampiris_folder');\nlet file = \"Lampiris_tarif_\" + Date().toString() + \".pdf\";\n\nmsg.filename = folder + file;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":1540,"wires":[["3c3e0504195ec439","f37ad39bdf1d2694"]]}]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [26 November 2021 10:42 UTC](https://discourse.nodered.org/t/downloading-pdf-file-from-internet/54324/2 "2021-11-26T10:42:15Z")

</div>

Check the output of the function node, particularly the filename. I think you might want  
`(new Date()).toString()`  
I don't know whether UTF8 string is the correct output format for the html node. It might be better as a binary buffer.

---

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [26 November 2021 11:07 UTC](https://discourse.nodered.org/t/downloading-pdf-file-from-internet/54324/3 "2021-11-26T11:07:36Z")

</div>

@Colin As always, you're right. Thanks very much for the help again !!!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [26 November 2021 11:11 UTC](https://discourse.nodered.org/t/downloading-pdf-file-from-internet/54324/4 "2021-11-26T11:11:12Z")

</div>

> [@henkkas](#):
>
> As always, you're right.

If only that were true.

Did you have to change it to a buffer?

---

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [28 November 2021 08:04 UTC](https://discourse.nodered.org/t/downloading-pdf-file-from-internet/54324/5 "2021-11-28T08:04:36Z")

</div>

Yes, indeed, @Colin , it is working perfectly now. As you might have seen, I needed that file to get elctricity tarifs from my distributor so I can update costprice in order to calculate energy costs. That's working now. Thanks!!!

greetings.

---

<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:** [27 January 2022 08:05 UTC](https://discourse.nodered.org/t/downloading-pdf-file-from-internet/54324/6 "2022-01-27T08:05:14Z")

</div>

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