the "hieght" and the 72dpi<->96dpi fixes

This commit is contained in:
notmasteryet 2011-06-29 22:43:59 -05:00
parent 29d0d8a8a9
commit 5ece4da552
8 changed files with 48 additions and 27 deletions

View file

@ -306,6 +306,13 @@ function WorkerPDFDoc(canvas) {
document.body.appendChild(div);
},
"setup_page": function(data) {
var size = data.split(",");
var canvas = this.canvas, ctx = this.ctx;
canvas.width = parseInt(size[0]);
canvas.height = parseInt(size[1]);
},
"fonts": function(data) {
this.waitingForFonts = true;
this.fontWorker.ensureFonts(data, function() {

View file

@ -31,6 +31,7 @@ importScripts("console.js")
importScripts("canvas.js");
importScripts("../pdf.js");
importScripts("../fonts.js");
importScripts("../crypto.js");
importScripts("../glyphlist.js")
// Use the JpegStreamProxy proxy.
@ -59,6 +60,18 @@ onmessage = function(event) {
// Let's try to render the first page...
var page = pdfDocument.getPage(parseInt(data));
var pdfToCssUnitsCoef = 96.0 / 72.0;
var pageWidth = (page.mediaBox[2] - page.mediaBox[0]) * pdfToCssUnitsCoef;
var pageHeight = (page.mediaBox[3] - page.mediaBox[1]) * pdfToCssUnitsCoef;
postMessage({
action: "setup_page",
data: pageWidth + "," + pageHeight
});
// Set canvas size.
canvas.width = pageWidth;
canvas.height = pageHeight;
// page.compile will collect all fonts for us, once we have loaded them
// we can trigger the actual page rendering with page.display
var fonts = [];