Stuck in jsPdf


#1

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


#2

You have a typo.

import jspdf from 'jspdf';

Should be…

import jsPDF from 'jspdf';

Easy to make work - look at this…


#3

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


#4

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.


#5

but where this a4.pdf getting stored


#6

That’s for you to work out


#7

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


#8

Yep and thanks will check that


#9

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?


#10

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


#11

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.


#12

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


#13

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