Open smart548 opened 6 years ago
I was able to get it working with: import html2pdf from 'html2pdf.js'
@cscanlin I installed the library using npm commands and imported with import html2pdf from 'html2pdf.js'
as mentioned by you. But I'm getting error that html2pdf is not a function. Can you please help me with this?
You'll have to inlcude it angular-cli.json under scripts like "scripts": [ "assets/js/html2pdf.bundle.js", ]
In your component: declare var html2pdf: any;
Now you can use html2pdf variable
const element = ele.nativeElement;
const opt = {
margin: 0,
filename: 'myfile.pdf',
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2 , dpi: 300,
letterRendering: true,
useCORS: true},
jsPDF: { unit: 'in', format: 'a4', orientation: 'portrait' }
};
// New Promise-based usage:
html2pdf().from(element).set(opt).save();
Hi, I've downloaded the library through the npm install command as suggested and everything installed in the node_modules folder as expected. The problem is that I don't know how to import it in my components; I've tried to:
Can you please elaborate on how can I use your lib in my project (or basically in any typescript project)?
Thank you.