Stuck in jsPdf

i am not able to get jspdf
my ts file

import jspdf from 'jspdf';
var doc = new jsPDF()

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

error I got is jspdf not defined

You have a typo.

import jspdf from 'jspdf';

Should be…

import jsPDF from 'jspdf';

Easy to make work - look at this…

1 Like

Hi
I actually want to make pdf from js data and then export so in jsPdf I am not able to understand

Name:'nikhil',
Id:'1',
data:'temp'

Name:'nikhil1',
Id:'2',
data:'temp1'

the above object I want to convert
Thanks

I’m not a jsPDF expert, and I knocked that last repo together in less than 5 minutes.

But, for a laugh… have another look at my project, just added an update which does the job.

but where this a4.pdf getting stored

That’s for you to work out

I think I deserve a couple thumbs ups for the trouble I’ve already gone to.

Yep and thanks will check that

Not slept a huge amount today so thought I’d have a look at the saving thing…

What did you actually want to do with the eventual PDF?

still not able to use in ionic I just want to export my data in PDF and save in mobile but looks like jsPdf is not for ionic 3
autoTable not working viewerPreferences not working

Okay - coz I’m a nice guy I’ve updated the repo to auto-save the resulting PDF to the device. Refer to the repo as mentioned above.

It’s using the Ionic Native File plugin…

You’ve got several options for where you wish to save the file and I have not researched them so you’ll probably need to do something in that region.

But let’s be honest - I’ve just got you 99% of the way there.

hey hi I have done that by using pdfmake
thanks for your help bro and will surely will check this one also and try to solve

Look at this solution => https://github.com/MarouaneSH/Ionic-jsPdf-Html2Canvas
it work fine