So I made a script that captures a div of my website and it starts downloading automatically.
The problem is that it only works on PC. I tried with a bunch of android phones and the picture does not download and gives an error that it can not be downloaded. what should I do for this situation?
The code :
html2canvas(document.getElementById("ssss"), {
useCORS: true
}).then(function (canvas) {
var imageURL = canvas.toDataURL("image/jpeg");
let a = document.createElement("a");
a.href = imageURL;
a.download = imageURL;
a.click();
});
Well I got the answer myself after dealing with the problem for hours I realized that all I needed to do was to add a few lines.
new Code :
html2canvas(document.getElementById("image-div-id"), {
imageTimeout: 15000, //newline
scale:3, //newline
useCORS: true
}).then(function (canvas) {
var imageURL = canvas.toDataURL("image/jpg");
let a = document.createElement("a");
a.href = imageURL;
a.download = "letter.jpg";
a.click();