'html2canvas image gets downloaded as Document on iOS chrome, works fine on Safari and Android Chrome etc
Here, i am using html2canvas to download a div as image in my react app, works fine on all browsers except iOS chrome. On iOS chrome it gets downloaded as document with no extension, on other browsers it gets downloaded as Jpeg image (which i want).
Code here
const downloadAsPng = (id) => {
setDownloadingIMG(true);
changeViewportToDesktop()
html2canvas(document.getElementById(id), {
useCORS: true,
scale: 2,
}).then(canvas => {
const link = document.createElement('a');
link.href = canvas.toDataURL('image/jpeg', 1.0);
link.download = 'eSportica-Stats.jpeg';
link.click();
setDownloadingIMG(false);
})
changeViewportToMobile()
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
