1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Property 'autoTable' does not exist on type jsPDF

Discussão em 'Angular' iniciado por Deep Kakkar, Outubro 7, 2024 às 05:02.

  1. Deep Kakkar

    Deep Kakkar Guest

    I am using angular2 and Node JS. I have installed jspdf and jspdf-autotable both modules using npm. In angular-cli.json file, I have embedded the scripts:

    "scripts": [
    "../node_modules/jspdf/dist/jspdf.min.js",
    "../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
    ],


    In my component.ts file , I have imported these files as follows:

    import * as jsPDF from 'jspdf';
    import * as autoTable from 'jspdf-autotable';


    I have also tried these lines to import jspdf-autotable

    import { autoTable } from 'jspdf-autotable';
    import 'jspdf-autotable';


    But nothing is working.

    In function of component.ts file I am using sample code as follows:

    var columns = ["ID", "Country", "Rank", "Capital"];
    var data = [
    [1, "Denmark", 7.526, "Copenhagen"],
    [2, "Switzerland", 7.509, "Bern"],
    [3, "Iceland", 7.501, "Reykjavík"],
    [4, "Norway", 7.498, "Oslo"],
    [5, "Finland", 7.413, "Helsinki"]
    ];
    var doc = new jsPDF();
    doc.autoTable(columns, data);
    doc.output("dataurlnewwindow");


    But now when I run the node command to start app then during compilation I am getting error as:


    Property 'autoTable' does not exist on type 'jsPDF'.

    Can any one please suggest?

    Continue reading...

Compartilhe esta Página