2

我正在使用 Google 组织图表 ( https://developers.google.com/chart/interactive/docs/gallery/orgchart ) 在我的网络应用程序中呈现图表。我将自定义格式添加到我的组织结构图节点。

我想添加将组织结构图另存为 PNG 的功能。为此,我尝试使用内置功能导出到 PNG(https://developers.google.com/chart/interactive/docs/printing)。

但是,当我使用上述方法将其导出为 PNG 时,组织结构图的所有格式都会丢失。我想导出它,以便在导出中完全保留组织结构图的外观。

关于如何实现这一点的任何指示?

4

1 回答 1

0

我想打印导致相同问题的组织结构图。通过包含 CSS 文件解决了它

function printDiv() 
{
var divToPrint=document.getElementById('chart_div');
var newWin=window.open('','Print-Window');
newWin.document.open();
newWin.document.write('<html>');
newWin.document.write('<link rel="stylesheet" href="/OrgChart.css" type="text/css" />');
newWin.document.write('<body onload="window.print)">'+divToPrint.innerHTML+'</body></html>');
newWin.document.close();
setTimeout(function(){newWin.close();},10);
}

HTML

<div id="tools"><a onclick=printDiv();>Print</a></div>
于 2018-09-14T20:39:28.333 回答