Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use pdf.js with Meteor?

Tags:

meteor

pdf.js

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

  • Placed index.html, hello.js, and pdf.js under the "clients" directory
  • Enclosed the contents of "hello.js" in a "Meteor.startup()" block
  • Stripped out almost everything from index.html:

    <body>
        <canvas id="the-canvas" style="border:1px solid black;"/>
    </body>
    

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

like image 498
user2242909 Avatar asked Apr 04 '13 01:04

user2242909


People also ask

What is PDF Viewer JS?

PDF. js is an open-source JavaScript PDF viewer that renders PDF using web standards-compliant HTML5. Primarily seen in Mozilla Firefox's as the built-in PDF viewer, PDF. js also serves as an easy way for developers and integrators to embed PDF viewing capabilities in a web app or server.

What is a PDF JS file?

js is a JavaScript library that renders Portable Document Format (PDF) files using the web standards-compliant HTML5 Canvas.

Is PDF JS open source?

PDF. js is an open source project and always looking for more contributors.


1 Answers

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

like image 167
Tarang Avatar answered Nov 15 '22 07:11

Tarang