angular-qr icon indicating copy to clipboard operation
angular-qr copied to clipboard

Download QR code image

Open dhiman252 opened this issue 9 years ago • 2 comments

I was wondering if could download the generated QR code as an image, I am using ionic framework and could not found hot this can be done.

dhiman252 avatar May 10 '16 10:05 dhiman252

@dhiman252 Any solution found ?

ArjunNagraj avatar Jun 15 '17 15:06 ArjunNagraj

I know this is a bad code, and it is not the best solution, but this works for web applications at least. It gets the canvas element and make a download link with this.

         function downloadQR() {
		var canvas = document.getElementsByTagName("canvas")[0];
		var img = canvas.toDataURL("image/png");
		var a = document.createElement('a');
		
		a.href = img;
		a.download = "image_qr.png";
		document.body.appendChild(a);
		a.click();
		document.body.removeChild(a);
	}

marcoshmendes avatar May 16 '19 00:05 marcoshmendes