pascoual:pdfjs

v1.1.114Published 9 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

pdfjs

PDF rendering for your Meteor application (client only). This package use the Mozilla's PDF reader built with HTML5 and JavaScript

If you need server side PDF rendering, please use pdf.js Meteor package from Mitar: https://github.com/peerlibrary/meteor-pdf.js

Quick Start

  1. `meteor add pascoual:pdfjs
  2. Exemple:
1<!-- In your template -->
2<canvas id="pdfcanvas"></canvas>
1/* In your Template.xxx.rendered */
2// Set worker URL to package assets
3PDFJS.workerSrc = '/packages/pascoual_pdfjs/build/pdf.worker.js';
4// Create PDF
5PDFJS.getDocument(url).then(function getPdfHelloWorld(pdf) {
6	// Fetch the first page
7	pdf.getPage(1).then(function getPageHelloWorld(page) {
8		var scale = 1;
9		var viewport = page.getViewport(scale);
10
11		// Prepare canvas using PDF page dimensions
12		var canvas = document.getElementById('pdfcanvas');
13		var context = canvas.getContext('2d');
14		canvas.height = viewport.height;
15		canvas.width = viewport.width;
16
17		// Render PDF page into canvas context
18		page.render({canvasContext: context, viewport: viewport}).promise.then(function () {
19			...
20		});
21	});
22});

Documentation

You can find informations about pdf.js lib:

Contributing

Contributors are very welcome. There are many things you can help with, including adding testing feature, creating examples for the examples folder... Some guidelines below:

  • Questions: It's okay to ask a question on Github Issues if you're having trouble since the volume is manageable. Just prefix your Github Issue with 'Question: ' so we can differentiate easily. Also, please make sure you've read through pdf.js documentation and tried a few things before asking. This way you can be very specific in your question. Also, please provide a cloneable Github repository if the issue is complex. For more complex questions sometimes it's hard to get all of the context required to solve a problem by just looking at text.

  • New Features & Bugs: You need to ask new features and bugs corrections to PDFjs creator on his GIT: http://mozilla.github.io/pdf.js/

  • Answer Questions!: If you can help another user please do!

TODO

  1. Explain how to make a viewer with selectable text
  2. Add testing

License

MIT