我有一个非常溢出的 div。它基本上包括一个大的组织结构图。我想要做的是使用 html2canvas 库导出 div 的全部内容而不是可见部分,但到目前为止我无法实现。以下代码不会呈现完整内容。有没有办法实现它?
function export(){
html2canvas( [ document.getElementById('diagram') ], {
onrendered: function(canvas) {
var dataUrl = canvas.toDataURL();
window.open(dataUrl, "toDataURL() image", "width=800, height=800");
//Canvas2Image.saveAsPNG(canvas);
}
});
}
我正在使用 BasicPrimitives 库来生成组织结构图。它需要一个 div 并向其中插入所有元素。由于我的图表比较大,它会从容器中溢出。Xhtml代码如下:
<rich:panel style="float: left; width: 100%;">
<div style="float: left; height:600px; margin-left: 1%; width: 19%; border-style: dotted; border-width:1px;">
Some irrelevant content
</div>
<div id="diagram" class='diagram' style="float: right; height:600px; width: 59%; border-style: dotted; border-width:1px;">
This is the div all charts are dynamically inserted
</div>
<div style="float: left; height:600px; margin-left: 1%; width: 19%; border-style: dotted; border-width:1px;">
Some more irrelevant content
</div>
</rich:panel>