# Html2canvas without internet access

**URL:** <https://discourse.nodered.org/t/html2canvas-without-internet-access/86438>\
**Category:** General\
**Created:** [14 March 2024 18:33 UTC](https://discourse.nodered.org/t/html2canvas-without-internet-access/86438 "2024-03-14T18:33:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![baboski](https://avatars.discourse-cdn.com/v4/letter/b/ecb155/32.png) [@baboski](https://discourse.nodered.org/u/baboski)\
**Post date:** [14 March 2024 18:33 UTC](https://discourse.nodered.org/t/html2canvas-without-internet-access/86438/1 "2024-03-14T18:33:33Z")

</div>

Hello, as i wrote in the title i would like to use html2canvas without internet access, i wanted to use again a code for a template that i already have but it works only with internet access because it uses:

```auto
<script src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.3.1/jspdf.umd.min.js"></script>

```

how can i achieve the same result without internet access? i tried to paste inside

```auto
<script>... </script>

```

the whole file present in [https://html2canvas.hertzen.com/dist/html2canvas.min.js](https://html2canvas.hertzen.com/dist/html2canvas.min.js) but it doesn't seem to work, thanks you

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [17 March 2024 12:00 UTC](https://discourse.nodered.org/t/html2canvas-without-internet-access/86438/2 "2024-03-17T12:00:47Z")

</div>

> [@baboski](#):
>
> i tried to paste inside
> 
> ```auto
> <script>... </script>
> 
> ```
> 
> the whole file present in [https://html2canvas.hertzen.com/dist/html2canvas.min.js](https://html2canvas.hertzen.com/dist/html2canvas.min.js) but it doesn't seem to work, thanks you

Where did you put it?

Assuming you are using `node-red-dashboard` (legacy) or `@flowfuse/node-red-dashboard` you can add that to a template node and it will add `html2canvas` to the `window object

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [17 March 2024 16:14 UTC](https://discourse.nodered.org/t/html2canvas-without-internet-access/86438/3 "2024-03-17T16:14:19Z")

</div>

It is much better to grab copies of the files from the Internet and then put them manually into a folder that you then define that folder in settings.js to be the `httpStatic` folder.

Having done that, you can change the existing script links to point to the static url in node-red.

Just remember to update the files occasionally from the Internet current versions.

---

<div class="post-metadata">

**Author:** ![baboski](https://avatars.discourse-cdn.com/v4/letter/b/ecb155/32.png) [@baboski](https://discourse.nodered.org/u/baboski)\
**Post date:** [18 March 2024 14:38 UTC](https://discourse.nodered.org/t/html2canvas-without-internet-access/86438/4 "2024-03-18T14:38:28Z")

</div>

I think that i don't have access to setting.js with my version of nodered (for ctrlx) this is why i was trying others solutions

---

<div class="post-metadata">

**Author:** ![baboski](https://avatars.discourse-cdn.com/v4/letter/b/ecb155/32.png) [@baboski](https://discourse.nodered.org/u/baboski)\
**Post date:** [18 March 2024 14:45 UTC](https://discourse.nodered.org/t/html2canvas-without-internet-access/86438/5 "2024-03-18T14:45:46Z")

</div>

I copied the whole .js file and paste it inside in a template node of the dashboard in which i have written the code to add the download button and all the code to generate the pdf to download

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [18 March 2024 16:07 UTC](https://discourse.nodered.org/t/html2canvas-without-internet-access/86438/6 "2024-03-18T16:07:04Z")

</div>

I tested putting the full code in a dashboard 2 (`@flowfuse/node-red-dashboard`) ui-template node between `<script>...</script>` tags & the `html2canvas` function was available in the `window` object (i.e. it does work).

I havent tried with a ui\_template on legacy dashboard (the older `node-red-dashboard`)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [18 March 2024 19:06 UTC](https://discourse.nodered.org/t/html2canvas-without-internet-access/86438/7 "2024-03-18T19:06:41Z")

</div>

I usually create an http endpoint for this that serves the javascript files which can be included with `<script src='....' />`

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/7/87f87434619a74bb4e25a3ceaaa36c57d063125a.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [18 March 2024 19:31 UTC](https://discourse.nodered.org/t/html2canvas-without-internet-access/86438/8 "2024-03-18T19:31:38Z")

</div>

if you are serving via http nodes as an endpoint, you should be serving the js without the script tags and add a `content-type` header set to `application/javascript`

---

<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:** [16 June 2024 19:31 UTC](https://discourse.nodered.org/t/html2canvas-without-internet-access/86438/9 "2024-06-16T19:31:44Z")

</div>

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