HTML2CANVAS not rendering the document.body when its more than 30,000 pixels long

本秂侑毒 提交于 2019-12-24 01:27:19

问题


is there anyway to solve this issue? The html2canvas is not rendering when the document.body height is more than 30,000 pixels. Or can i render the current viewport only? On what the user can see?

Please help.


回答1:


To be able to render only current active viewport you can initialize html2canvas with type:'view' option

example:

 var body = document.getElementsByTagName("body")[0]; 
    html2canvas(body, {
        type: 'view',
        onrendered: function(canvas) {
            //implementation
        }
    })

I tested the above code with html2canvas version 0.5.0-beta4 and it capture only the current viewport correctly, even if you scroll to the bottom of the page

Regarding 30,000 pixels, you can check the answer mentioned by @kaiido



来源:https://stackoverflow.com/questions/46881957/html2canvas-not-rendering-the-document-body-when-its-more-than-30-000-pixels-lon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!