Browse Source

PDF.js version 1.2.38 - See mozilla/pdf.js@335aeb2e3749993efe9ad85a21cffa65dc0a2369

master v1.2.38
Pdf Bot 9 years ago
parent
commit
b6983f7776
  1. 2
      bower.json
  2. 4
      build/pdf.combined.js
  3. 4
      build/pdf.js
  4. 4
      build/pdf.worker.js
  5. 2
      package.json
  6. 59
      web/pdf_viewer.js

2
bower.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "1.2.36", "version": "1.2.38",
"main": [ "main": [
"build/pdf.js", "build/pdf.js",
"build/pdf.worker.js" "build/pdf.worker.js"

4
build/pdf.combined.js

@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {}; (typeof window !== 'undefined' ? window : this).PDFJS = {};
} }
PDFJS.version = '1.2.36'; PDFJS.version = '1.2.38';
PDFJS.build = 'd26ef21'; PDFJS.build = '335aeb2';
(function pdfjsWrapper() { (function pdfjsWrapper() {
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it

4
build/pdf.js

@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {}; (typeof window !== 'undefined' ? window : this).PDFJS = {};
} }
PDFJS.version = '1.2.36'; PDFJS.version = '1.2.38';
PDFJS.build = 'd26ef21'; PDFJS.build = '335aeb2';
(function pdfjsWrapper() { (function pdfjsWrapper() {
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it

4
build/pdf.worker.js vendored

@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {}; (typeof window !== 'undefined' ? window : this).PDFJS = {};
} }
PDFJS.version = '1.2.36'; PDFJS.version = '1.2.38';
PDFJS.build = 'd26ef21'; PDFJS.build = '335aeb2';
(function pdfjsWrapper() { (function pdfjsWrapper() {
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "1.2.36", "version": "1.2.38",
"description": "Generic build of Mozilla's PDF.js library.", "description": "Generic build of Mozilla's PDF.js library.",
"keywords": [ "keywords": [
"Mozilla", "Mozilla",

59
web/pdf_viewer.js

@ -249,6 +249,55 @@ function binarySearchFirstItem(items, condition) {
return minIndex; /* === maxIndex */ return minIndex; /* === maxIndex */
} }
/**
* Approximates float number as a fraction using Farey sequence (max order
* of 8).
* @param {number} x - Positive float number.
* @returns {Array} Estimated fraction: the first array item is a numerator,
* the second one is a denominator.
*/
function approximateFraction(x) {
// Fast paths for int numbers or their inversions.
if (Math.floor(x) === x) {
return [x, 1];
}
var xinv = 1 / x;
var limit = 8;
if (xinv > limit) {
return [1, limit];
} else if (Math.floor(xinv) === xinv) {
return [1, xinv];
}
var x_ = x > 1 ? xinv : x;
// a/b and c/d are neighbours in Farey sequence.
var a = 0, b = 1, c = 1, d = 1;
// Limiting search to order 8.
while (true) {
// Generating next term in sequence (order of q).
var p = a + c, q = b + d;
if (q > limit) {
break;
}
if (x_ <= p / q) {
c = p; d = q;
} else {
a = p; b = q;
}
}
// Select closest of the neighbours to x.
if (x_ - a / b < c / d - x_) {
return x_ === x ? [a, b] : [b, a];
} else {
return x_ === x ? [c, d] : [d, c];
}
}
function roundToDivide(x, div) {
var r = x % div;
return r === 0 ? x : Math.round(x - r + div);
}
/** /**
* Generic helper to find out what elements are visible within a scroll pane. * Generic helper to find out what elements are visible within a scroll pane.
*/ */
@ -1207,10 +1256,12 @@ var PDFPageView = (function PDFPageViewClosure() {
} }
} }
canvas.width = (Math.floor(viewport.width) * outputScale.sx) | 0; var sfx = approximateFraction(outputScale.sx);
canvas.height = (Math.floor(viewport.height) * outputScale.sy) | 0; var sfy = approximateFraction(outputScale.sy);
canvas.style.width = Math.floor(viewport.width) + 'px'; canvas.width = roundToDivide(viewport.width * outputScale.sx, sfx[0]);
canvas.style.height = Math.floor(viewport.height) + 'px'; canvas.height = roundToDivide(viewport.height * outputScale.sy, sfy[0]);
canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px';
canvas.style.height = roundToDivide(viewport.height, sfy[1]) + 'px';
// Add the viewport so it's known what it was originally drawn with. // Add the viewport so it's known what it was originally drawn with.
canvas._viewport = viewport; canvas._viewport = viewport;

Loading…
Cancel
Save