Create image more than screenshot with html2canvas

758 views Asked by At

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..

1

There are 1 answers

0
Dixit On

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();
 }
});