简体   繁体   中英

Create image more than screenshot with html2canvas

I have this code

html2canvas($(".container"), {imageTimeout: 2000, removeContainer: true}).then(function(canvas) {
   img = canvas.toDataURL("image/png"),
   doc = new jsPDF({
     unit: 'px',
     format: 'a4'
   });
    window.open(img);
});

I would like that all HTML in $(".container") appeared in my image, but it only creates image with HTML that appeared in screen..

What i understand i write this code. Hope this code help you.

html2canvas($("#container"), {
 onrendered: function (canvas) {
         var imgData = canvas.toDataURL('image/png');
         var a = document.createElement('a');
         a.href = imgData ;
         a.download = 'somefilename.png';
         a.click();
 }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM