Hi! I’m a to Meteor newb and also relatively new to Web Development. I was wondering how to use third party javascript libraries such as pdfmake (https://github.com/bpampuch/pdfmake) in my Meteor app.
In a simple plain html file, you would have a “script src…” tag in the head, with the location of the directory where the pdfmake .js files were saved, and you could then directly use the pdfmake functions.
I know atmospherejs have some pdf printing packages, but I like the functionality of pdfmake and I also want to know whether it is possible to use any third party libraries, or can you only use ones that have been packaged already for meteor?
If u have a .js and .css file than In your project create client folder and create a new two folder lib and css in client folder than move your .js file in lib folder and .css file in css folder -I wish it’s work for you
All resources in “public” folder are served to internet.
So you can simple create “public” folder in your project root directory and place hello_world.js into it.
Than load it in header by that script src=“hello_world.js”, not sure if u need “/” at the start .
Wow, 2 responses within an hour! Thanks so much for your help. I have got it working, by putting the pdfmake js files in the public folder and then referencing them by doing script src ="…/…/public/pdfmake.min.js"
If I put them in the lib folder, I get this error (I think it might be because pdfmake is for the client side only?):
Your app is crashing. Here’s the latest log.
/Users/tinazhang/.meteor/packages/meteor-tool/.1.0.40.1mb1y9p++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:173
throw(ex);
^
TypeError: Cannot read property ‘document’ of undefined
at o (app/lib/pdfmake.min.js:2:222)
at Object. (app/lib/pdfmake.min.js:2:2489)
at Object.t.length (app/lib/pdfmake.min.js:2:2715)
at e (app/lib/pdfmake.min.js:1:142)
at Object. (app/lib/pdfmake.min.js:1:448)
at Object.fontDescriptors (app/lib/pdfmake.min.js:1:2247)
at e (app/lib/pdfmake.min.js:1:142)
at Object. (app/lib/pdfmake.min.js:1:285)
at Object.docDefinition (app/lib/pdfmake.min.js:1:292)
at e (app/lib/pdfmake.min.js:1:142)
at app/lib/pdfmake.min.js:1:229
at app/lib/pdfmake.min.js:1:234
at app/lib/pdfmake.min.js:24:3
at /Users/tinazhang/Documents/Coursework/Thesis/Meteor/workflow-routing/webapp/.meteor/local/build/programs/server/boot.js:205:10
at Array.forEach (native)
at Function..each..forEach (/Users/tinazhang/.meteor/packages/meteor-tool/.1.0.40.1mb1y9p++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
at /Users/tinazhang/Documents/Coursework/Thesis/Meteor/workflow-routing/webapp/.meteor/local/build/programs/server/boot.js:116:5
Exited with code: 8
Your application is crashing. Waiting for file change.