bubkoo / html-to-image

✂️ Generates an image from a DOM node using HTML5 canvas and SVG.
MIT License
5.79k stars 544 forks source link

TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'. #54

Closed DavidTawil closed 3 years ago

DavidTawil commented 4 years ago

I have a project with few charts, and I want to create a pdf (using react-pdf) with those charts as images. I've set the id for one of the charts and tried the example code as shown in the usage section:

 var node = document.getElementById("bp-graph");

    htmlToImage
      .toPng(node)
      .then(function (dataUrl) {
        console.log("inside");
        var bpImage = new Image();
        bpImage.src = dataUrl;
        document.body.appendChild(bpImage);
      })
      .catch(function (error) {
        console.error("oops, something went wrong!", error);
      });

but I'm getting the error in the title, any idea why, or what I need to change?

rajanaggarwal1 commented 4 years ago

did you find the solution?

DavidTawil commented 4 years ago

I didn't, and actually switched to html2canvas instead. I think they work the same, and my issue was I couldn't reach the element because it was in another component

biiibooo[bot] commented 4 years ago

Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not-stale" to keep this issue open! As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request.

Thanks for being a part of the Antv community! 💪💯

biiibooo[bot] commented 3 years ago

Hey again! It’s been 60 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to comment on this issue or create a new one if you need anything else. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Thanks again for being part of the Antv community! 💪💯

stefnotch commented 3 years ago

Reproducing an issue like that from just a description is quite tricky. That's probably why you never got a response. I'd recommend whipping up a minimal project that reproduces that error and report it.

biiibooo[bot] commented 2 years ago

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.