【发布时间】:2016-10-26 05:58:04
【问题描述】:
有没有人使用 jsPDF autoTable 从表格中排除 pdf 结果中的列..会有所帮助。
【问题讨论】:
标签: javascript jquery jspdf jspdf-autotable
有没有人使用 jsPDF autoTable 从表格中排除 pdf 结果中的列..会有所帮助。
【问题讨论】:
标签: javascript jquery jspdf jspdf-autotable
无论如何,在深入研究 API 和示例之后。我找到了解决方案。带有 autoTable 的 jsPDF 对于初学者来说有点棘手,所以对于那些在不久的将来会遇到这种困境的人来说。方法如下:
var tTB = document.getElementById("myTable");
var atTB = doc.autoTableHtmlToJson(tTB, true);
var cols = atTB.columns;
//here you are going to set which column you will truncate. Moreover, .splice(index number of the column(your start), the number of columns you will exclude)
cols.splice(4,1);
doc.text("My Test Table", 40, 60);
doc.autoPrint();
干杯!
【讨论】:
doc.autoPrint 是如何工作的,但是如果你想调用doc.autoTable,你需要将列和行传递给它。因此,您还需要遍历所有行并拼接要忽略的列,否则显示的数据可能与正确的列不对应。不过,你把我送到了正确的方向。
您可以使用http://pdfmake.org/ 生成pdf 客户端。使用这个库编写 pdf 文件要简单得多。他们还有游乐场可以复制粘贴您的代码并观看实时 pdf。
谢谢,
【讨论】: