HTML2CANVAS在超过30,000像素长时不呈现document.body [英] HTML2CANVAS not rendering the document.body when its more than 30,000 pixels long
问题描述
无论如何都要解决这个问题?当document.body高度超过30,000像素时,html2canvas不会渲染。或者我可以只渲染当前视口吗?用户可以看到什么?
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?
请帮忙。
推荐答案
为了能够只渲染当前活动视口,您可以使用初始化html2canvas:'view'
选项
To be able to render only current active viewport you can initialize html2canvas with type:'view'
option
示例:
var body = document.getElementsByTagName("body")[0];
html2canvas(body, {
type: 'view',
onrendered: function(canvas) {
//implementation
}
})
我用 html2canvas
version <$测试了上面的代码c $ c> 0.5.0-beta4 并且它只会正确捕获当前视口,即使您滚动到页面底部
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
关于30,000像素,您可以查看@kaiido提到的答案
Regarding 30,000 pixels, you can check the answer mentioned by @kaiido
这篇关于HTML2CANVAS在超过30,000像素长时不呈现document.body的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!