GithubHelp home page GithubHelp logo

tongji1907 / meteor-pdf.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from peerlibrary/meteor-pdf.js

0.0 2.0 0.0 1.13 MB

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

Home Page: https://github.com/mozilla/pdf.js

License: Other

JavaScript 51.50% CoffeeScript 48.50%

meteor-pdf.js's Introduction

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++

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.