Merge to upstream
This commit is contained in:
commit
3973b01ec9
1
LICENSE
1
LICENSE
@ -3,6 +3,7 @@
|
||||
|
||||
Contributors: Andreas Gal <gal@mozilla.com>
|
||||
Chris G Jones <cjones@mozilla.com>
|
||||
Shaon Barman <shaon.barman@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -564,7 +564,7 @@ var Type1Parser = function(aAsciiStream, aBinaryStream) {
|
||||
var decryptedString = [];
|
||||
|
||||
var value = "";
|
||||
var count = aStream.length - aStream.start;
|
||||
var count = aStream.length;
|
||||
for (var i = 0; i < count; i++) {
|
||||
value = aStream.getByte();
|
||||
decryptedString[i] = String.fromCharCode(value ^ (r >> 8));
|
||||
|
BIN
compressed.tracemonkey-pldi-09.pdf
Normal file
BIN
compressed.tracemonkey-pldi-09.pdf
Normal file
Binary file not shown.
@ -1,4 +1,5 @@
|
||||
<html>
|
||||
<<<<<<< HEAD
|
||||
<head>
|
||||
<title>Simple pdf.js page viewer</title>
|
||||
<link rel="stylesheet" href="test.css"></link>
|
||||
@ -16,6 +17,7 @@
|
||||
<button onclick="nextPage();">Next</button>
|
||||
<input type="text" id="pageNumber" onchange="gotoPage(this.value);"
|
||||
value="1" size="4"></input>
|
||||
<span id="numPages">--</span>
|
||||
<span id="info"></span>
|
||||
</div>
|
||||
|
||||
|
28
test.js
28
test.js
@ -5,9 +5,23 @@ var pdfDocument, canvas, pageDisplay, pageNum;
|
||||
function load() {
|
||||
canvas = document.getElementById("canvas");
|
||||
canvas.mozOpaque = true;
|
||||
open("uncompressed.tracemonkey-pldi-09.pdf");
|
||||
pageNum = parseInt(queryParams().page) || 1;
|
||||
fileName = queryParams().file || "compressed.tracemonkey-pldi-09.pdf";
|
||||
open(fileName);
|
||||
}
|
||||
|
||||
function queryParams() {
|
||||
var qs = window.location.search.substring(1);
|
||||
var kvs = qs.split("&");
|
||||
var params = { };
|
||||
for (var i = 0; i < kvs.length; ++i) {
|
||||
var kv = kvs[i].split("=");
|
||||
params[unescape(kv[0])] = unescape(kv[1]);
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
function open(url) {
|
||||
document.title = url;
|
||||
req = new XMLHttpRequest();
|
||||
@ -19,12 +33,20 @@ function open(url) {
|
||||
var data = req.mozResponseArrayBuffer || req.mozResponse ||
|
||||
req.responseArrayBuffer || req.response;
|
||||
pdfDocument = new PDFDoc(new Stream(data));
|
||||
displayPage(1);
|
||||
numPages = pdfDocument.numPages;
|
||||
document.getElementById("numPages").innerHTML = numPages.toString();
|
||||
goToPage(pageNum);
|
||||
}
|
||||
};
|
||||
req.send(null);
|
||||
}
|
||||
|
||||
function gotoPage(num) {
|
||||
if (0 <= num && num <= numPages)
|
||||
pageNum = num;
|
||||
displayPage(pageNum);
|
||||
}
|
||||
|
||||
function displayPage(num) {
|
||||
document.getElementById("pageNumber").value = num;
|
||||
|
||||
@ -59,7 +81,7 @@ function prevPage() {
|
||||
displayPage(--pageNum);
|
||||
}
|
||||
|
||||
function gotoPage(num) {
|
||||
function goToPage(num) {
|
||||
if (0 <= num && num <= numPages)
|
||||
displayPage(pageNum = num);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user