vue.jspdfkitmaker-js

Vue and pdfkit generates an error: not constructor


I installed pdfkit in my Vue.js app then I created a vue component to start creating PDF but on my first test I got an error:

Component script:

const pdfkit =  require('pdfkit');
var doc = new pdfkit;

But this generates an error:

pdfkit is not a constructor

How to fix it? Thanks for any suggetsion


Solution

  • Try to import it in your component with

    import pdfkit from 'pdfkit'
    

    and then create your document with

    let doc = new pdfkit();