Skip to content

pascoual/meteor-pdfjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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. Install the Meteor package using mgp
  2. Example:
<!-- In your template -->
<canvas id="pdfcanvas"></canvas>
/* In your Template.xxx.rendered */
import PDFJS from 'meteor/geekho:pdfjs';

// Set worker URL to package assets
PDFJS.GlobalWorkerOptions.workerSrc = '/packages/geekho_pdfjs/build/pdf.worker.js';
// Create PDF
PDFJS.getDocument(url).promise.then(function getPdfHelloWorld(pdf) {
	// Fetch the first page
	pdf.getPage(1).then(function getPageHelloWorld(page) {
		var scale = 1;
		var viewport = page.getViewport({ scale });

		// Prepare canvas using PDF page dimensions
		var canvas = document.getElementById('pdfcanvas');
		var context = canvas.getContext('2d');
		canvas.height = viewport.height;
		canvas.width = viewport.width;

		// Render PDF page into canvas context
		page.render({canvasContext: context, viewport: viewport}).promise.then(function () {
			...
		});
	});
});

Documentation

You can find information about pdf.js lib:

License

MIT

About

PDF rendering for your Meteor application (client only).

Resources

Stars

Watchers

Forks

Packages

No packages published