ReferenceError: jsPDF is not defined

Hi, I’m facing a tiny issue though I don’t know how to fix it.

I’m trying to use jsPDF libary to generate pdf using vue.js.

I simply install jsPDF

npm install jspdf --save

and try this sample code

var doc = new jsPDF()

doc.text('Hello world!', 10, 10)
doc.save('a4.pdf')

It gives me this error

ReferenceError: jsPDF is not defined

It seems vue doesn’t know anything about the jsPDF module. I think I can’t use Vue.use(jsPDF)
becasue jsPDF is not a vue.js pluggin. So how can I export this libary to my project?

Thnaks in advanced!

Thanks a lot. I used require instead of import that’s why this happen. :sunglasses:

Hi. I’m that problem, i have a simple code, but get this error

    import jsPDF from 'jspdf'
    import 'jspdf-autotable'

    function tt(){
        console.log("clicou em gerar relatorios")
        var doc = new jsPDF()
        console.log("criou um jsPDF")
        doc.text('Hello world!', 10, 10)
        doc.save('a4.pdf')

What i have change?