HTML2Canvas converting overflowed content to image

前端 未结 2 1346
甜味超标
甜味超标 2020-12-14 22:13

I have a div which is pretty overflowed. It basically includes a big organization chart. What I want to do is exporting whole content of div rather than visible part with ht

2条回答
  •  爱一瞬间的悲伤
    2020-12-14 23:01

    Give a try to dom-to-image, it works better for me since I have to set specific size, and show and element that hides for some screen size:

    function convertCanvasAndSend(idElement, nameImage) {
    var element = document.getElementById(idElement);
    var styleOrig = element.getAttribute("style");
    element.setAttribute("style", "width: 1400px; height: 480px;");
    element.querySelector("ANY_HIDDEN_YOU NEED").setAttribute("style", "display: block;");
    domtoimage.toBlob(element)
    .then(function (blob) {
        window.saveAs(blob, nameImage + '.png');
        element.setAttribute("style", styleOrig);
        element.querySelector("ANY_HIDDEN_YOU NEED").setAttribute("style", styleOrigInnDiv);
    });
    

    }

提交回复
热议问题