Html2canvas only captures screens, not the entire div container

I am trying to grab the entire div container in one image using html2canvas. For some reason im only gets the part that appears on my screen. But I have horizontal scrolling on the div, so I would like to capture what was not on my screen, but the contents inside the div.

Is it possible? Right now my div is 5,000 pixels wide, can I somehow capture it in one image?

Here is my javascript code for html2canvas:

$(function() { 
 $("#btnSave").click(function() {
 });
    html2canvas($("#container_wrapper_anatomy"), {
        onrendered: function(canvas) {
            theCanvas = canvas;

            var dataUrl = canvas.toDataURL();
            window.open(dataUrl, "toDataURL() image", "width=100%, height=100%");

            canvas.toBlob(function(blob) {
                saveAs(blob, "container_wrapper_anatomy.jpg"); 
              });
          }
      });
  });
});

Thanks in advance.

+4
source share

Source: https://habr.com/ru/post/1619188/


All Articles