我正在使用jsPDF和jsPDF autotable创建pdf文件,但创建的pdf文件为空。没有错误,我检查了行是否为空,但它们不是。 当它长达43页the pdf file generated
时,我不知道为什么它是空的这是我的代码:
$scope.export = function(){
var columns = ["Name", "Cellphone", "Work Phone"];
var rows = [];
for (var i = 0; i < $scope.data.length; i++) {
rows.push({ employeename:$scope.data[i].employeename, cell_phone:$scope.data[i].cell_phone, work_phone:$scope.data[i].work_phone});
}
var doc = new jsPDF('p', 'pt');
doc.autoTable(columns, rows);
doc.save('jspdf-test312.pdf');
}
答案 0 :(得分:3)
解决了!我一直在列表中推送一个对象。它应该是列表中的列表。
$scope.export = function(){
var columns = ["Name", "Cellphone", "Work Phone"];
var rows = [];
for (var i = 0; i < $scope.data.length; i++) {
rows.push([ $scope.data[i].employeename, $scope.data[i].cell_phone, $scope.data[i].work_phone]);
}
var doc = new jsPDF('p', 'pt');
doc.autoTable(columns, rows);
doc.save('jspdf-test312.pdf');
}