HTML2CANVAS not rendering the document.body when i

2019-07-13 03: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