I am using html2canvas to convert html to image (PNG file) and trigger download in user's device. I have tested the code, works well in all desktop browser but not working in IOS and android webview. Below is the code I am using:
$('#btnDownload').click(function () {
$('.section-loading').show();
html2canvas($('#divDownload'),
{
background: '#fff',
onrendered: function (canvas) {
if (navigator.userAgent.indexOf("MSIE ") > 0 ||
navigator.userAgent.match(/Trident.*rv\:11\./)) {
var blob = canvas.msToBlob();
window.navigator.msSaveBlob(blob, 'Receipt.png');
}
else {
$('#download').attr('href', canvas.toDataURL("image/png"));
$('#download').attr('download', 'Receipt.png');
$('#download')[0].click();
}
$('.section-loading').hide();
}
});
});