I would like to show a PDF file in dashboard.
File is stored in home/www/cpt/manuali with name Manuale_palletizzatore.pdf
The IP address of node red is 192.168.99.2
I try to use a template node with this code:
var manuale = function()
window.location.href = "http://192.168.99.2/Manuali/Manuale_palletizzatore.pdf";
But it doesn't work!
Why in your opinion?
I just read your post over again and spotted that the way you’re trying to access your file is incorrect. Node-RED (thankfully) doesn’t have access to arbitrary files inside the home folder of the user who runs it. You need to put it in the static files directory, then build the correct link for node-red. You should be able to find that by a forum search.
Old reply below:
Is your goal to display the PDF within the dashboard, or redirect to the file? If to redirect, use a link (
<a href="Address here">) instead. If to embed, take a look at pdfjs, a Mozilla library that is a PDF viewer written fully in HTML5
first of all many thanks for reply.
My problem is that the PDF file must be located inside NodeRed machine in home/www/cpt/manuali
Keep in mind that if I use the same code in a Raspberry configuration all works well.
In my opionion is a problem of NodeRed or Linux configuration that not grant the correct access to the home/www/cpt/manuali but I cannot understand how.
Port is the standard 1880
In that case one of the reasons it doesn’t work is that you’re trying to show the file from port 80 and just hope it works. Is there a webserver running on your device exposing everything in your home folder? If the answer is no which I do hope, check the link from my previous message and try that approach as it is the recommended way.
I install Apache Web Server and now web server function well.
I bolded a part of my previous answer. Running a separate web server is not a good nor secure solution for your issue if you expose your entire home directory to it. Node-RED is in a way a webserver, and setting up the static files folder does exactly what you need.
I put my pdf file inside nodered static folder, then I use button node to open the file but no working. Am I doing it wrongly?
Yes, please take a look at post #4 in this thread. On top of that, you cannot use absolute paths to somewhere on your harddrive in an
a href, but you have to point to a web address relative to the static folder for the node red web server to see it.
Beyond that remains the same question as I posted to the first poster of this thread, are you trying to embed the PDF file, or show a link to it? If you’re trying to display it as link your current method should work once you change the path. For embedding/showing the pdf within the dashboard, this won’t be enough.