how to use jsPDF and jspdf-autotable in angular 5

后端 未结 10 858
北海茫月
北海茫月 2021-01-06 01:46

I am trying to use jsPDF and jspdf-autotable in my Angular 5.2.0 project. My package.json is below (related parts):

\"dependencies\": {
    ...
    \"jspdf\"         


        
10条回答
  •  孤城傲影
    2021-01-06 02:37

    To work with jspdf-autotable in angular 5, one must install jspdf and jspdf-autotable via npm

    npm install jspdf-autotable --save
    

    also add the jspdf and jspdf-autotable files to the scripts array in angular-cli.json

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

    and in component never import jspdf or jspdf-autotable just

    declare var jsPDF: any;
    

    Of course before working with jspdf-autotable one should install jspdf and for development @types/jspdf via npm

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

提交回复
热议问题