PDFMake in angularjs
I'm building a MEAN-app from the meanjs.org build. I tried injecting pdfMake in this mean app and I can't find a way to get this working. Any idea how to fix this?
The error I keep on getting when building with grunt:
pdfMake.createPdf(docDefinition); ^ 'pdfMake' is not defined.
I'm using PDFMake in Angular and Ionic.
Check if you added pdfmake.min.js in index.html.
I installed using bower install --save pdfmake, then grunt's wiredep should add 'bower_components/pdfmake/build/pdfmake.min.js' to your index.html, before your app definition in app.js.
If you have a reference to pdfmake.js as a script in your index then you should have access to pdfMake object.
I am using typescript and I simply declare the object as any declare let pdfMake: any;
and use it:
private init(): void {
let docDefinition: any = { content: 'This is an sample PDF printed with pdfMake' };
pdfMake.createPdf(docDefinition).open();
}
Is there any way to import pdfmake via npm to use in an Angularjs app? (I'm not talking about server-side examples you have for node).
I also need to print angularjs {{ values }} from templates to pdf but I found no way to do this in my views. Can someone share an example?