使用jsPDF-AutoTable仅以pdf格式下载表格的一页

时间:2017-10-13 08:22:45

标签: javascript pdf jspdf-autotable

我想下载一个表格内容的pdf文件。为此我使用jsPDF-AutoTable库。但是当我下载文件时它只下载一页。我的代码如下。请告诉我,我应该怎么做改变我的代码?

<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js"</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/2.3.2/jspdf.plugin.autotable.js"></script>
<script>
function download_pdf(val) {
    if (val == 3) {
       var doc = new jsPDF('p', 'pt');
       var elem = document.getElementById("myTable");
       var res = doc.autoTableHtmlToJson(elem);
       doc.autoTable(res.columns, res.data,{ 
       styles: {overflow: 'linebreak'},
       columnStyles: {
       0: {columnWidth: 50}, 
       1:{columnWidth:50}, 
       2: {columnWidth: 50}, 
       3: {columnWidth: 40},
       4: {columnWidth: 40}, 
       5:{columnWidth:40}, 
       6: {columnWidth: 40}, 
       7: {columnWidth: 40},
       8: {columnWidth: 40}, 
       9:{columnWidth:40}, 
       10: {columnWidth: 40}, 
       11: {columnWidth: 40},
       12: {columnWidth: 40}
       }
       });
       doc.save("can_data_report.pdf");
   }
}
</script>

0 个答案:

没有答案