I'm developping an app with cordova and AngularJS.
I installed pdfmake with npm install pdfmake and when I load it with require('pdfmake'), it showed me thsi error : Uncaught TypeError: fs.readFileSync is not a function.
Kind regards
npm package is primarily for server side usage. If you want use it in client side use files in build folder. For example: require('pdfmake/build/pdfmake.js'); and fonts require('pdfmake/build/vfs_fonts.js');.
@liborm85 now i get : Cannot set property 'c' of undefined
my boostrap.js code:
`try {
//window.$ = window.jQuery = require('jquery');
global.$ = global.jQuery = require('jquery');
window.dt = require('datatables.net');
require( 'datatables.net-fixedcolumns' );
require( 'jszip' );
require('pdfmake/build/pdfmake.js');
require('pdfmake/build/vfs_fonts.js');
require( 'datatables.net-buttons' )();
require( 'datatables.net-buttons/js/buttons.colVis.js' )();
require( 'datatables.net-buttons/js/buttons.html5.js' )();
require( 'datatables.net-buttons/js/buttons.print.js' )();
require('select2');
} catch (e) {
console.error(e.message);
}`
No answer to @legreco ? I have the same problem!
Yes same problem for me also. Please help me to sort of this issue. @liborm85
@ramprakashjagadeesan please do try this package pdfmake-browserified
@Philip-Nunoo Thanks for your response. I founded another solution. Its Working.
Most helpful comment
npm package is primarily for server side usage. If you want use it in client side use files in
buildfolder. For example:require('pdfmake/build/pdfmake.js');and fontsrequire('pdfmake/build/vfs_fonts.js');.