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
- `meteor add pascoual:pdfjs
- 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:
- pdf.js web site: http://mozilla.github.io/pdf.js/
- pdf.js API: https://github.com/mozilla/pdf.js/blob/master/src/display/api.js
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
- Explain how to make a viewer with selectable text
- Add testing
License
MIT