2011-09-27 05:28:16 +09:00
|
|
|
|
2011-09-15 09:34:29 +09:00
|
|
|
//
|
|
|
|
// See README for overview
|
|
|
|
//
|
|
|
|
|
2011-09-27 05:28:16 +09:00
|
|
|
'use strict';
|
2011-09-15 09:34:29 +09:00
|
|
|
|
2012-04-13 00:23:38 +09:00
|
|
|
//
|
2013-06-03 06:51:08 +09:00
|
|
|
// Fetch the PDF document from the URL using promises
|
2012-04-13 00:23:38 +09:00
|
|
|
//
|
|
|
|
PDFJS.getDocument('helloworld.pdf').then(function(pdf) {
|
|
|
|
// Using promise to fetch the page
|
|
|
|
pdf.getPage(1).then(function(page) {
|
|
|
|
var scale = 1.5;
|
|
|
|
var viewport = page.getViewport(scale);
|
2011-09-15 09:34:29 +09:00
|
|
|
|
2012-04-13 00:23:38 +09:00
|
|
|
//
|
|
|
|
// Prepare canvas using PDF page dimensions
|
|
|
|
//
|
|
|
|
var canvas = document.getElementById('the-canvas');
|
|
|
|
var context = canvas.getContext('2d');
|
|
|
|
canvas.height = viewport.height;
|
|
|
|
canvas.width = viewport.width;
|
2011-09-15 09:34:29 +09:00
|
|
|
|
2012-04-13 00:23:38 +09:00
|
|
|
//
|
|
|
|
// Render PDF page into canvas context
|
|
|
|
//
|
|
|
|
var renderContext = {
|
|
|
|
canvasContext: context,
|
|
|
|
viewport: viewport
|
|
|
|
};
|
|
|
|
page.render(renderContext);
|
|
|
|
});
|
2011-09-15 09:34:29 +09:00
|
|
|
});
|