pdfmake icon indicating copy to clipboard operation
pdfmake copied to clipboard

PDFMake in angularjs

Open BramDecuypere opened this issue 10 years ago • 4 comments

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.

BramDecuypere avatar Jan 11 '16 15:01 BramDecuypere

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.

ramonsan avatar Jan 18 '16 08:01 ramonsan

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();
 }

iberodev avatar Aug 10 '16 01:08 iberodev

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).

varunsharma27 avatar Jun 20 '17 21:06 varunsharma27

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?

staminna avatar Oct 06 '17 13:10 staminna