1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-24 09:08:07 +02:00

Support for multi-size page PDFs

This commit is contained in:
notmasteryet 2011-06-26 09:15:33 -05:00
parent 7b931b3635
commit 5d154e04bf
5 changed files with 45 additions and 20 deletions

BIN
test/pdfs/sizes.pdf Normal file

Binary file not shown.

View file

@ -25,5 +25,10 @@
"link": true,
"rounds": 1,
"type": "load"
},
{ "id": "sizes",
"file": "pdfs/sizes.pdf",
"rounds": 1,
"type": "eq"
}
]

View file

@ -25,9 +25,6 @@ function load() {
manifestFile = params.manifestFile;
canvas = document.createElement("canvas");
// 8.5x11in @ 100% ... XXX need something better here
canvas.width = 816;
canvas.height = 1056;
canvas.mozOpaque = true;
stdout = document.getElementById("stdout");
@ -93,7 +90,6 @@ function nextPage() {
log(" loading page "+ currentTask.pageNum +"... ");
var ctx = canvas.getContext("2d");
clear(ctx);
var fonts = [];
var gfx = null;
@ -105,6 +101,15 @@ function nextPage() {
failure = 'compile: '+ e.toString();
}
try {
// using mediaBox for the canvas size
canvas.width = currentPage.mediaBox[2];
canvas.height = currentPage.mediaBox[3];
clear(ctx);
} catch(e) {
failure = 'page setup: '+ e.toString();
}
var fontLoaderTimer = null;
function checkFontsLoaded() {
try {
@ -193,7 +198,6 @@ function sendTaskResult(snapshot) {
}
function clear(ctx) {
var ctx = canvas.getContext("2d");
ctx.save();
ctx.fillStyle = "rgb(255, 255, 255)";
ctx.fillRect(0, 0, canvas.width, canvas.height);