Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image is not generated by html2canvas in firefox without giving any errors #2046

Open
po95 opened this issue Oct 22, 2019 · 8 comments
Open

Comments

@po95
Copy link

po95 commented Oct 22, 2019

Here is my code of generating a image on chrome, firefox and other browsers. When i click on my function to generate a image in firefox, the browser holds the request and after sometime it prints some outputs without downloading the image

var node = document.querySelector("#pop-up-table");
            html2canvas(node, {}).then(function(canvas){
                var userAgent = navigator.userAgent;
                var a = document.createElement('a');
                if(userAgent.search('Chrome') >= 0){
                    a.href = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
                    a.download = 'table.png';
                } else {
                    a.href = canvas.toDataURL("image/jpeg").replace("image/jpeg", "image/octet-stream");
                    a.download = 'table.jpg';
                }
                a.click();
            });

I modified the code slightly for firefox (will generate jpg for firefox and other browsers) other than chrome because of a claim on a comment in this post (here)

16df332f834 0ms Starting document clone                                   html2canvas.min.js:20:84099
16df332f834 3798ms Document cloned, using computed rendering              html2canvas.min.js:20:84099
16df332f834 3799ms Starting DOM parsing                                   html2canvas.min.js:20:84099
16df332f834 10556ms Starting renderer                                     html2canvas.min.js:20:84099
16df332f834 10557ms Canvas renderer initialized 
(770x1184 at 197,96.60000610351562)with scale 1                           html2canvas.min.js:20:84099
16df332f834 27498ms Finished rendering                                    html2canvas.min.js:20:84099

Have seen these solutions below but it didn't bring any good:

NB: I call this code snippet in a setTimeout() function and increasing time didn't help

@drxcheng
Copy link

same

@praveenkumarhopscotch
Copy link

praveenkumarhopscotch commented May 14, 2020

same problem facing

@swvv
Copy link

swvv commented May 30, 2020

same

@UserHuRu
Copy link

UserHuRu commented Aug 3, 2020

same~ but is sometimes in mobile

@gillespieza
Copy link

me too

@JordanBoulan
Copy link

JordanBoulan commented Apr 14, 2021

same problem. I tried using 'image/jpeg', but still not working for me.
image

@chua1989
Copy link

chua1989 commented Sep 6, 2022

same to me

@sharmavj89
Copy link

Facing similar issue on ios (all browsers) but working fine on every other device. Anyone found a solution yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants