je hebt nodig html2canvas en canvas2image
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | (function ($, root, undefined) { 'use strict'; $(document).ready(function($) { $("#download-calender").click(function(e) { e.preventDefault(); var img = { image_pro: null }; html2canvas(document.getElementById('section-calender-print')).then(function(canvas) { cp(canvas); }); // here send canvas to cp var cp = function(canvas) { var image_cv = Canvas2Image.convertToPNG(canvas); //to generate an image from canvas img.image_pro = image_cv.getAttribute('src'); var a = document.createElement('a'); a.download = "calender.png"; a.href = $(image_cv).attr('src'); document.body.appendChild(a); a.click(); document.body.removeChild(a); }; }); }); })(jQuery, this); |