Skip to content
Loading
0
  • Muthu Kumar
    0
    HI Nithi Mano,

    Here is an example for jspdf.

    Install following,

    npm install jspdf --save
    npm install @types/jspdf --save-dev
    npm install jspdf-autotable --save

    Add this lines in angular.json file,
    1. "scripts": [  
    2. "../node_modules/jspdf/dist/jspdf.min.js",  
    3. "../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"  
    4. ],  
    For Call component,
    1. declare var jsPDF: any;  
    2.    
    3.   
    4. downloadPDF() {  
    5.   
    6.         let columns = ["ID", "Name", "Country"];  
    7.         let rows = [  
    8.             [1, "Shaw", "Tanzania"],  
    9.             [2, "Nelson", "Kazakhstan"],  
    10.             [3, "Garcia", "Madagascar"],  
    11.         ];  
    12.   
    13.         let doc = new jsPDF('l', 'pt');  
    14.         doc.autoTable(columns, rows); // typescript compile time error  
    15.         doc.save('table.pdf');  
    16.         }  
    17.     }  
    Reference:-

    https://stackoverflow.com/questions/49445269/how-to-use-jspdf-and-jspdf-autotable-in-angular-5

    I hope it's solve your problem.
    0