Html-pdf Node Error

Hello -

I'm getting the below error when trying to use the html-pdf node on a rasberry pi zero. When running the same flow on a windows machine I'm successful. I've looked around the internet and found a few folks having the same issues but haven't seen any solutions that have worked for me.

Any ideas here?

html-pdf: Failed to load PhantomJS module. You have to set the path to the PhantomJS binary using 'options.phantomPath'

Flows:

[{"id":"a2ca1b99.8e3b58","type":"inject","z":"dab759db.e53268","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":580,"y":300,"wires":[["749a0511.1f7fbc"]]},{"id":"7c709ea2.06658","type":"HTML-PDF","z":"dab759db.e53268","name":"HTML-PDF","output":"buffer","x":1050,"y":300,"wires":[["e04af8f8.c83988"]]},{"id":"dae17c02.27b01","type":"template","z":"dab759db.e53268","name":"HTML","field":"payload","fieldType":"msg","format":"html","syntax":"mustache","template":"\n\n\n \n Basic Web Page\n \n \n \n \t\n <h3 style="text-align:center">Test Message Header\n\n

Test Message <span style="color: blue;">

\n \n\n","output":"str","x":890,"y":300,"wires":[["7c709ea2.06658"]]},{"id":"e04af8f8.c83988","type":"file","z":"dab759db.e53268","name":"","filename":"test.pdf","appendNewline":true,"createDir":true,"overwriteFile":"true","x":1220,"y":300,"wires":[]},{"id":"749a0511.1f7fbc","type":"function","z":"dab759db.e53268","name":"Variables","func":"msg.site = 9999;\nmsg.date = 8888;\nmsg.row_number = 7777;\nmsg.unit_number = 6666;\nmsg.gear_box_date_code = 5555;\nmsg.gear_box_hours_in_service = 4444;\nmsg.gear_box_years_in_service = 3333;\nmsg.rbc_years_in_service = 2222;\nmsg.torque_arm_angle = 1111;\nmsg.peak_torque = 1212;\nmsg.max_imbalance = 1313;\n\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":300,"wires":[["dae17c02.27b01"]]}]

Are you talking about the node node-red-contrib-pdf ? If so I would suggest opening an inside on the nodes github page as you cannot guarantee that the author will read this forum

Have you installed the pre-reqs for linux... ?

have you figure out a solution ?

Have any one found the solution? I have this same problem on Windows server. The git hub repository link is not valid anymore. I can't reach the author.

Can anyone help?

"This repository has been archived by the owner. It is now read-only."

I'm afraid that you will need to find something else or fork the module and fix the error then get the node's author to change to your fork.

I don't know how to edit nodes ;/
are there people who need to display data in the form of a pdf report in the node red forum? Does only a handful of people need it and it is not the main topic? :stuck_out_tongue:

I think that, from the previous replies, not many people were that engaged I'm afraid. I'd love to help but unfortunately, I'm already over-committed with other work and projects.

I do note that there are a number of ways to convert HTML to PDF with the help of Node.js (which is what underpins Node-RED). It may be that you can find another Node.js module and get it to work with Node-RED. You can require() Node.js modules onto the global variables from settings.js and then access that in a function node and there is a reasonable chance that will work. But obviously, it does need some JavaScript knowledge.

Thank you, I didn't know that. I will try that if this node fails me again.

I spend some time again on that node trying to make it work again and I didn't read this thread. It turned out that when I set it up on Windows Server sometimes it opens several instances of the node red and then this error happens.

After ending all of instances and starting again Node-Red the error disappears and HTML-PDF node works again like on normal Windows.

So you are running Node-RED just to do the conversion? How are you starting it up? Do you really have multiple instances of Node-RED left running or are those cmd.exe entries the result of your Node-RED flow running the converter that maybe runs a background command shell? If you add the "Command Line" column to the task manager, you should be able to see exactly what is being run.

Node-RED itself appears as a node.js executable:

The conhost entries are the underlying terminal feature of Windows, you don't need to worry about those. You will get one for each shell command (cmd.exe, powershell.exe or pwsh.exe)

Yes, I run Node-red.cmd to run my program, is there a simpler way to start my flow after I write the program on my server? What did you mean by "conversion"?

I have set Task Scheduler to run C:\Users\Wojtek\AppData\Roaming\npm\node-red.cmd
then my program appears in the localhost and the user can use it from user's computer.

And yes, there are sometimes a few instances of this two commands shells and always only one instance of Node.js (green icon) but then the problem with generating pdfs appears. And I think it is sctricte Task Scheduler fault and my poor understanding of it.

No, that's fine, just checking that you didn't have Node-RED running as a service which many people do.

HTML-to-PDF

Actually, I think it may be the software's fault because I think that it is starting a shell process but that isn't finishing. So if you run the flow again, you probably get a second shell that doesn't end. Maybe it isn't doing it all the time but there is something that stops the shell from ending.

Don't really think I can help further - as the underlying library is no longer supported, I'm not sure what can be done.

Is it always the same web page you are trying to convert?

I wrote my own template to use it with this HTML-PDF node and I only populate it with different data, so yes.
Ok thank you for your support. I think I can go by myself from this point. Thank so much

OK, no problem. The thing is, if you are using your own template then I wouldn't do it that way at all. I would pass the data to a command line converter and do it all that way. Simple and robust.

could you be more specific? What command line converter? Is there a converter to meke pdfs? :stuck_out_tongue:

https://www.startpage.com/do/dsearch?query=windows+command+line+convert+html+to+pdf&cat=web&pl=opensearch&language=english

Plenty.

Pandoc is one of the most commonly used and converts masses of different formats.

https://pandoc.org/installing.html

  1. What you are using as an internet search engine :stuck_out_tongue:

  2. How about that. I didn't know that. I will try it. Can you copy this to the second (my) thread about pdf making?

Startpage.com - it is a privacy focused search engine. I only ever use Google if I can't find things using startpage. You may have heard of the alternative which is DuckDuckGo. I used to use DDG but found that SP has some slightly better search options.