# I cant convert HTML to PDF or Print the HTML content

**URL:** <https://discourse.nodered.org/t/i-cant-convert-html-to-pdf-or-print-the-html-content/62163>\
**Category:** General\
**Created:** [4 May 2022 09:46 UTC](https://discourse.nodered.org/t/i-cant-convert-html-to-pdf-or-print-the-html-content/62163 "2022-05-04T09:46:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fireboyff](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@fireboyff](https://discourse.nodered.org/u/fireboyff)\
**Post date:** [4 May 2022 09:46 UTC](https://discourse.nodered.org/t/i-cant-convert-html-to-pdf-or-print-the-html-content/62163/1 "2022-05-04T09:46:42Z")

</div>

Hi

I've been trying to convert HTML content that is created in my flow to a PDF for days. Unfortunately, all attempts have failed.  
I also display this HTML content in the dashboard in a Ui\_Tamplet, it would also be enough for me if I could print the content via the web browser via the Print button. However, in this case he always wants to print the whole page (including the menus and the other UI\_Elements)

**So my goal would be to print out the HTML content that is also displayed in the Ui\_Tamplet, either via browser or as a PDF download and print out the PDF.**

I've tried the Html-\>PDF Node. However, I have the problem when I send the HTML content via msh.payload and send the necessary settings with msg.config. Crashes Node-Red completely, I haven't found a log about it yet. _Export below._

My other attempt was via Functions Node. I have included the jspdf.js library in the settings.js and wanted to solve it via script.  
Test Code:

```auto
var doc = jsPDF();
doc.text(20, 20, 'Hello, world.');
msg.payload = doc.save('Test.pdf', function(err){console.log('saved!');});

return msg;

```

However, I get the error: **"ReferenceError: jsPDF is not defined (line 1, col 11)"**

All other solutions that I found via Google or in this forum either didn't work or gave an error.

I guess the solution will definitely be very simple and afterwards I'll be annoyed why I didn't think of it myself, but at the moment I don't know what to do next. So I would ask for your help.

Thanks  
Fire

Export from html-\>PDF node Test:

> **Summary**
>
> [  
> {  
> "id": "0df5361b58930300",  
> "type": "inject",  
> "z": "4b32b97b46f1f41f",  
> "name": "",  
> "props": [  
> {  
> "p": "payload"  
> },  
> {  
> "p": "options",  
> "v": "{"format":"A4","orientation":"portrait","border":{"top":"2in","right":"1in","bottom":"2in","left":"1.5in"},"header":{"height":"45mm"},"zoomFactor":"1","type":"pdf","quality":"75","phantomPath":"./node\_modules/phantomjs/bin/phantomjs"}",  
> "vt": "json"  
> },  
> {  
> "p": "filename",  
> "v": "test.pdf",  
> "vt": "str"  
> }  
> ],  
> "repeat": "",  
> "crontab": "",  
> "once": false,  
> "onceDelay": 0.1,  
> "topic": "",  
> "payload": " /\* Font Definitions _/ @font-face \t{font-family:"Cambria Math"; \tpanose-1:2 4 5 3 5 4 6 3 2 4;} @font-face \t{font-family:Calibri; \tpanose-1:2 15 5 2 2 2 4 3 2 4;} /_ Style Definitions _/ p.MsoNormal, li.MsoNormal, div.MsoNormal \t{margin-top:0cm; \tmargin-right:0cm; \tmargin-bottom:8.0pt; \tmargin-left:0cm; \tline-height:107%; \tfont-size:11.0pt; \tfont-family:"Calibri",sans-serif; \t} p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing \t{margin:0cm; \tfont-size:11.0pt; \tfont-family:"Calibri",sans-serif; \t} .MsoChpDefault \t{font-family:"Calibri",sans-serif;} .MsoPapDefault \t{margin-bottom:8.0pt; \tline-height:107%;} /_ Page Definitions \*/ @page WordSection1 \t{size:595.3pt 841.9pt; \tmargin:36.0pt 36.0pt 36.0pt 36.0pt;} div.WordSection1 \t{page:WordSection1; \t} \tdiv.A4O { \twidth: 210mm; \theight: 297mm; \tborder-style: outset; \tborder-width: 3px; \tbox-shadow: 5px 5px 5px black; \t} div.Abst{ \tmargin: 15mm 15mm 15mm 15mm; \t}
> 
>  
> 
> \<span style="position:relative;z-index:40"\> \<img width=107 height=107 src="[https://upload.wikimedia.org/wikipedia/commons/thumb/6/61/QR\_deWP.svg/1200px-QR\_deWP.svg.png](https://upload.wikimedia.org/wikipedia/commons/thumb/6/61/QR_deWP.svg/1200px-QR_deWP.svg.png)"\> 
> 
> **Combies: \_\_\_**
> 
> **{{Tabel\_Select\_Infos.CU\_contact}}**
> 
> **Auftrag AU{{Tabel\_Select\_Infos.AU\_pk}}**
> 
> **&nbsp;**
> 
> **{{Tabel\_Select\_Infos.CU\_name}}**
> 
> Liefterm: **{{Tabel\_Select\_Infos.AU\_shipment\_date}} 08:00**
> 
> Erstellt: _xxx_
> 
> &nbsp;
> 
> **Positionen**
> 
> &nbsp;
> 
> {{{tabelle}}} 
> 
> | 
> 
> **Teil**
> 
> | 
> 
> **Anzahl**
> 
> | 
> 
> **Referenz**
> 
> | 
> 
> **Notiz**
> 
> |
> 
>  
>  
>  
> ",  
> "payloadType": "str",  
> "x": 3760,  
> "y": 440,  
> "wires": [  
> [  
> "e2addfc797a30765",  
> "6907616fbfbd56b0"  
> ]  
> ]  
> },  
> {  
> "id": "6907616fbfbd56b0",  
> "type": "HTML-PDF",  
> "z": "4b32b97b46f1f41f",  
> "name": "HTML-PDF",  
> "output": "file",  
> "x": 3930,  
> "y": 440,  
> "wires": [  
> [  
> "ff3519cc83848547"  
> ]  
> ]  
> },  
> {  
> "id": "ff3519cc83848547",  
> "type": "debug",  
> "z": "4b32b97b46f1f41f",  
> "name": "",  
> "active": true,  
> "tosidebar": true,  
> "console": false,  
> "tostatus": false,  
> "complete": "true",  
> "targetType": "full",  
> "statusVal": "",  
> "statusType": "auto",  
> "x": 4110,  
> "y": 440,  
> "wires":   
> },  
> {  
> "id": "e2addfc797a30765",  
> "type": "debug",  
> "z": "4b32b97b46f1f41f",  
> "name": "",  
> "active": true,  
> "tosidebar": true,  
> "console": false,  
> "tostatus": false,  
> "complete": "true",  
> "targetType": "full",  
> "statusVal": "",  
> "statusType": "auto",  
> "x": 3900,  
> "y": 400,  
> "wires":   
> }  
> ]

---

<div class="post-metadata">

**Author:** ![fireboyff](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@fireboyff](https://discourse.nodered.org/u/fireboyff)\
**Post date:** [6 May 2022 08:26 UTC](https://discourse.nodered.org/t/i-cant-convert-html-to-pdf-or-print-the-html-content/62163/2 "2022-05-06T08:26:26Z")

</div>

Hi

After a long search I was able to solve my problem.  
I don't want to withhold my solution from you, maybe one of you may need this information.

I now create my PDF with the HTML-PDF node (_ **node-red-contrib-pdf** _). Here, however, I always had the error "_ **Auto configuration failed** _", so I left this node and was looking for other solutions.

To fix this "_ **Auto configuration failed** _" error, you just have to do the following steps.

1. Go to /etc/ssl/openssl.cnf
2. Find the following line and comment it.

```auto
# System default
openssl_conf = default_conf

```

1. Restart your node-red server

After that the HTML-PDF node works fine.

I hope I can make someone's life easier with this.

Kind regards, Fire

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [6 May 2022 10:06 UTC](https://discourse.nodered.org/t/i-cant-convert-html-to-pdf-or-print-the-html-content/62163/3 "2022-05-06T10:06:18Z")

</div>

@fireboyff FYI  
I would be wary of this node since it:

1. hasn't been updated (as of the date of this post) in over SIX years
2. the repository on GitHub is gone
3. the GitHub user seems to be missing.

So realize that if anything goes wrong (say a future NR or node.js update breaks it), you're on your own with it.

---

<div class="post-metadata">

**Author:** ![fireboyff](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@fireboyff](https://discourse.nodered.org/u/fireboyff)\
**Post date:** [6 May 2022 10:32 UTC](https://discourse.nodered.org/t/i-cant-convert-html-to-pdf-or-print-the-html-content/62163/4 "2022-05-06T10:32:20Z")

</div>

Hi zenofmud

Yes, I'm aware of that, but I haven't found a better solution after more than a week of searching.

The integration of e.g. jsPDF.js in the function node does not work.  
Unfortunately, all other attempts didn't work either.

Best regards Fire

---

<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:** [20 May 2022 10:32 UTC](https://discourse.nodered.org/t/i-cant-convert-html-to-pdf-or-print-the-html-content/62163/5 "2022-05-20T10:32:23Z")

</div>

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