简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM