All Projects → peerlibrary → meteor-pdf.js

peerlibrary / meteor-pdf.js

Licence: other
Mozilla's HTML5 PDF reader, repackaged for Meteor, client & server

Programming Languages

javascript
184084 projects - #8 most used programming language
coffeescript
4710 projects

pdf.js smart package

Meteor smart package for pdf.js, Mozilla's PDF reader built with HTML5 and JavaScript that powers the PDF display in Firefox. Now as a Meteor package for both client and server side. This package just renders PDFs not creates them.

Adding this package to your Meteor application adds PDFJS object into the global scope, which you can use as defined in pdf.js API. On the server, in addition to existing API, a fibers-enabled synchronous (blocking) methods are added to objects. They are named the same, but with a Sync suffix. Instead of returning a promise they return when they finish or throw an exception. So, on the server you can do:

var pdf = {
    data: Assets.getBinary(pdfPath),
    password: ''
};
var document = PDFJS.getDocumentSync(pdf);
var page = document.getPageSync(1);

If not using Assets to get PDF, you should use fs package for file system access to get fibers-enabled synchronous functions instead of functions which block the whole node.js process.

Installation

meteor add peerlibrary:pdf.js

Building

It requires some additional node.js packages which will be automatically locally installed from npm when Meteor builds the package for the first time.

The following libraries have to be available on your system for packages to be successfully built:

On Mac OS X you can get Cairo by installing X11 (Pango and FreeType are already available on the system) and run the following before you run mrt to configure the environment:

export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig

To be able to compile dependencies, you need Xcode with command line tools installed (from Preferences > Downloads > Components).

You can install pkg-config, giflib, and libjpeg using Homebrew (MacPorts also works, if you prefer it):

brew install pkg-config giflib libjpeg

On Debian you can install all dependencies by:

sudo aptitude install libcairo2-dev libfreetype6-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].