2014-09-01 19 views
0

我正在將Highcharts圖表和HTML表格導出爲PDF,但是當我的表格很大時,它無法正確放置在PDF頁面中。在Highcharts導出中使用A3頁面

我使用導出PDF:

Highcharts.getSVG = function(charts) { 
    var svgArr = [], 
     top = 0, 
     width = 0; 

    $.each(charts, function(i, chart) { 
     var svg = chart.getSVG(); 
     svg = svg.replace('<svg', '<g transform="translate(0,' + top + ')" '); 
     svg = svg.replace('</svg>', ' <h2 style="position: absolute; color: #333; right: 0px; width: 50%; top: 10px; text-align: center">' + titulo + '</h2></g>'); 

     top += chart.chartHeight; 
     width = Math.max(width, chart.chartWidth); 

     svgArr.push(svg); 
    }); 

    tabela = $("#mainTabela").clone(); 
    top += tabela.height(); 

    svgArr.push('<g transform="translate(0,' + top + ')">' + tabela.html() + ' </g>'); 
    return '<svg height="'+ top +'" width="' + width + '" version="1.1" xmlns="http://www.w3.org/2000/svg">' + svgArr.join('') + '</svg>'; 
}; 

有出口時使用的A3頁面的方法嗎?或者只是使用更大的頁面?表

例由不同的頁面分爲:

Table divided by pages

回答

0

的問題是,我得到了臺克隆的高度,也就是0。所以我PDF的高度始終是圖表高度,而忽略了表的大小。

我只是改變:

top += tabela.height(); 

爲:

if($("#mainTabela").height() > top) 
     top = $("#mainTabela").height(); 

,它的工作現在