dom-to-image icon indicating copy to clipboard operation
dom-to-image copied to clipboard

Uncaught (in promise)

Open stefan-reich opened this issue 3 years ago • 5 comments

Yup... I got it too. No particular reason I can think of. Two images are from a foreign server - but that shouldn't break the whole process?

Screenshot

Demo

What I called:

  domtoimage.toJpeg(document.body, { quality: 0.95 })
    .then(function (dataUrl) {
        var link = document.createElement('a');
        link.download = 'gazelle-screenshot.jpg';
        link.href = dataUrl;
        link.click();
    });

stefan-reich avatar Jun 27 '21 01:06 stefan-reich

PS: Switched to html2canvas, works like a charm

stefan-reich avatar Jun 27 '21 01:06 stefan-reich

I had this same issue when I had local images in my page (file:///) and I found this happens because a part in the library's code expects the servers response status code to be 200 on success. So as far as what I can see from the screenshot you shared, the server serving those images are not sending 200 status code instead it sent 0.

shaikh-amaan-fm avatar Jul 06 '21 20:07 shaikh-amaan-fm

Yeah the images are on a different domain and dom-to-image cannot fetch them. Maybe that's what broke the whole thing. I'm using html2canvas now BTW, it's the same as dom-to-image but in, uh, "works".

stefan-reich avatar Jul 06 '21 20:07 stefan-reich

had the same issue,how did you solve it?

sujiangyin avatar Oct 05 '23 14:10 sujiangyin