user2242909
user2242909

Reputation: 61

How to use pdf.js with Meteor?

I've been trying to get the helloworld example for pdf.js to run in Meteor. So far I have:

I thought this was enough to have the example working, but Meteor ends up complaining about the "!DOCTYPE html" declaration in pdf.js, which doesn't exist inside the file, so I am guessing that it gets imported from somewhere.

It feels like I'm missing something obvious to get this working, is there an easy solution for this?

(Aside: I am aware of the pdf.js smart package, but since I am doing development on Windows it's not really an option for me because I can't get Meteorite. Although I figure that since a smart package already exists, it's quite doable get the two to work together.)

Upvotes: 6

Views: 1846

Answers (2)

Rune Jeppesen
Rune Jeppesen

Reputation: 1131

You could also use the Jquery getScript and load it externally. I have used this in the template.rendered (enables text selection - if you don't need that you could settle with less):

$.getScript( "http://vivin.net/pub/pdfjs/pdf.js" );
$.getScript( "http://vivin.net/pub/pdfjs/textlayerbuilder.js" );

Callback function can be given as argument: http://api.jquery.com/jquery.getscript/

Upvotes: 0

Tarang
Tarang

Reputation: 75985

Meteor shouldn't really complain about the doctype declaration in js files. Is this a built version of pdf.js?

You can technically use atmosphere packages in your project by copying over the files as described in package.js and smart.json at the repo, in this case at https://github.com/peerlibrary/meteor-pdf.js

i.e add coffeescript & underscore (in api.use)

meteor add coffeescript underscore

Then copy the files over to your server dir: (as in api.add_files)

 bootstrap.coffee
 server.coffee

Then you have it installed as if it were put in by meteorite only the files are physically put in, additionally a node module is also required as described at https://github.com/peerlibrary/meteor-pdf.js

Upvotes: 1

Related Questions