how to use jsPDF and jspdf-autotable in angular 5

后端 未结 10 855
北海茫月
北海茫月 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:46

    If you could use declare var jsPDF: any; it is working for Chrome, IE and other browsers too, but it is not working for Firefox browser.

    In this case, you could follow the below steps:

    declare const require: any;
    const jsPDF = require('jspdf');
    require('jspdf-autotable');
    

    and other parts remain same like:

    npm install jspdf --save
    npm install @types/jspdf --save-dev
    npm install jspdf-autotable --save
    
    "scripts": [
        "../node_modules/jspdf/dist/jspdf.min.js",
        "../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
    ],
    

    So, it will defiantly work on all the browsers. how simple it is :)

提交回复
热议问题