Search Posts

Empty rows when creating pdf using jsPDF and jsPDF autotable

I am creating a pdf file using jsPDF and jsPDF autotable but the created pdf file is empty. There are no errors, I have checked the rows if empty but they are not.
I do not know why its empty when it is 43-pages long the pdf file generated

here is my code:

$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');
    }

Source: AngularJS

1 comment on Empty rows when creating pdf using jsPDF and jsPDF autotable

  1. $scope.export = function(){
    var columns = [“Name”, “Cellphone”, “Work Phone”];
    var rows = [];
    for (var i in $scope.data ) {
    var temp=[$scope.data[i].employeename,$scope.data[i].cell_phone,$scope.data[i].work_phone]
    rows.push(temp);
    }
    var doc = new jsPDF(‘p’, ‘pt’);
    doc.autoTable(columns, rows);
    doc.save(‘jspdf-test312.pdf’);
    }

    Ubove code should work

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.