update pdf.js
Before Width: | Height: | Size: 371 B After Width: | Height: | Size: 272 B |
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 268 B |
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 268 B |
Before Width: | Height: | Size: 371 B After Width: | Height: | Size: 272 B |
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 340 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 315 B |
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 414 B |
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 414 B |
Before Width: | Height: | Size: 454 B After Width: | Height: | Size: 290 B |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 244 B After Width: | Height: | Size: 210 B |
Before Width: | Height: | Size: 512 B After Width: | Height: | Size: 343 B |
Before Width: | Height: | Size: 237 B After Width: | Height: | Size: 200 B |
Before Width: | Height: | Size: 417 B After Width: | Height: | Size: 348 B |
Before Width: | Height: | Size: 558 B After Width: | Height: | Size: 462 B |
Before Width: | Height: | Size: 353 B After Width: | Height: | Size: 296 B |
Before Width: | Height: | Size: 426 B After Width: | Height: | Size: 310 B |
Before Width: | Height: | Size: 344 B After Width: | Height: | Size: 307 B |
Before Width: | Height: | Size: 491 B After Width: | Height: | Size: 450 B |
Before Width: | Height: | Size: 474 B After Width: | Height: | Size: 437 B |
Before Width: | Height: | Size: 503 B After Width: | Height: | Size: 411 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 583 B |
Before Width: | Height: | Size: 302 B After Width: | Height: | Size: 296 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 548 B |
Before Width: | Height: | Size: 349 B After Width: | Height: | Size: 306 B |
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 405 B |
Before Width: | Height: | Size: 300 B After Width: | Height: | Size: 261 B |
Before Width: | Height: | Size: 211 B After Width: | Height: | Size: 182 B |
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 141 B |
|
@ -38,7 +38,7 @@ print.title=Imprimir
|
||||||
print_label=Imprimir
|
print_label=Imprimir
|
||||||
download.title=Descargar
|
download.title=Descargar
|
||||||
download_label=Descargar
|
download_label=Descargar
|
||||||
bookmark.title=Vista actual (copie o abra en una ventana nueva)
|
bookmark.title=Vista actual (para copiar o abrir en otra ventana)
|
||||||
bookmark_label=Vista actual
|
bookmark_label=Vista actual
|
||||||
|
|
||||||
# Secondary toolbar and context menu
|
# Secondary toolbar and context menu
|
||||||
|
@ -57,6 +57,11 @@ page_rotate_ccw.title=Girar a la izquierda
|
||||||
page_rotate_ccw.label=Girar a la izquierda
|
page_rotate_ccw.label=Girar a la izquierda
|
||||||
page_rotate_ccw_label=Girar a la izquierda
|
page_rotate_ccw_label=Girar a la izquierda
|
||||||
|
|
||||||
|
hand_tool_enable.title=Activar la herramienta Mano
|
||||||
|
hand_tool_enable_label=Activar la herramienta Mano
|
||||||
|
hand_tool_disable.title=Desactivar la herramienta Mano
|
||||||
|
hand_tool_disable_label=Desactivar la herramienta Mano
|
||||||
|
|
||||||
# Tooltips and alt text for side panel toolbar buttons
|
# Tooltips and alt text for side panel toolbar buttons
|
||||||
# (the _label strings are alt text for the buttons, the .title strings are
|
# (the _label strings are alt text for the buttons, the .title strings are
|
||||||
# tooltips)
|
# tooltips)
|
||||||
|
@ -133,4 +138,4 @@ password_cancel=Cancelar
|
||||||
printing_not_supported=Aviso: Este navegador no es compatible completamente con la impresión.
|
printing_not_supported=Aviso: Este navegador no es compatible completamente con la impresión.
|
||||||
printing_not_ready=Aviso: El PDF no se ha cargado completamente para su impresión.
|
printing_not_ready=Aviso: El PDF no se ha cargado completamente para su impresión.
|
||||||
web_fonts_disabled=Se han desactivado los tipos de letra web: no se pueden usar los tipos de letra incrustados en el PDF.
|
web_fonts_disabled=Se han desactivado los tipos de letra web: no se pueden usar los tipos de letra incrustados en el PDF.
|
||||||
web_colors_disabled=Se han desactivado los colores web.
|
document_colors_disabled=No se permite que los documentos PDF usen sus propios colores: la opción «Permitir que las páginas elijan sus propios colores» está desactivada en el navegador.
|
||||||
|
|
|
@ -20,8 +20,8 @@ if (typeof PDFJS === 'undefined') {
|
||||||
(typeof window !== 'undefined' ? window : this).PDFJS = {};
|
(typeof window !== 'undefined' ? window : this).PDFJS = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
PDFJS.version = '0.8.798';
|
PDFJS.version = '0.8.846';
|
||||||
PDFJS.build = '5b0eebb';
|
PDFJS.build = '05f937e';
|
||||||
|
|
||||||
(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
|
||||||
|
@ -43,7 +43,8 @@ PDFJS.build = '5b0eebb';
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* globals Cmd, ColorSpace, Dict, MozBlobBuilder, Name, PDFJS, Ref, URL */
|
/* globals Cmd, ColorSpace, Dict, MozBlobBuilder, Name, PDFJS, Ref, URL,
|
||||||
|
Promise */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -51,9 +52,6 @@ var globalScope = (typeof window === 'undefined') ? this : window;
|
||||||
|
|
||||||
var isWorker = (typeof window == 'undefined');
|
var isWorker = (typeof window == 'undefined');
|
||||||
|
|
||||||
var ERRORS = 0, WARNINGS = 1, INFOS = 5;
|
|
||||||
var verbosity = WARNINGS;
|
|
||||||
|
|
||||||
var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
|
var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
|
||||||
|
|
||||||
var TextRenderingMode = {
|
var TextRenderingMode = {
|
||||||
|
@ -78,6 +76,12 @@ if (!globalScope.PDFJS) {
|
||||||
|
|
||||||
globalScope.PDFJS.pdfBug = false;
|
globalScope.PDFJS.pdfBug = false;
|
||||||
|
|
||||||
|
PDFJS.VERBOSITY_LEVELS = {
|
||||||
|
errors: 0,
|
||||||
|
warnings: 1,
|
||||||
|
infos: 5
|
||||||
|
};
|
||||||
|
|
||||||
// All the possible operations for an operator list.
|
// All the possible operations for an operator list.
|
||||||
var OPS = PDFJS.OPS = {
|
var OPS = PDFJS.OPS = {
|
||||||
// Intentionally start from 1 so it is easy to spot bad operators that will be
|
// Intentionally start from 1 so it is easy to spot bad operators that will be
|
||||||
|
@ -182,21 +186,19 @@ var log = (function() {
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// A notice for devs that will not trigger the fallback UI. These are good
|
// A notice for devs. These are good for things that are helpful to devs, such
|
||||||
// for things that are helpful to devs, such as warning that Workers were
|
// as warning that Workers were disabled, which is important to devs but not
|
||||||
// disabled, which is important to devs but not end users.
|
// end users.
|
||||||
function info(msg) {
|
function info(msg) {
|
||||||
if (verbosity >= INFOS) {
|
if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.infos) {
|
||||||
log('Info: ' + msg);
|
log('Info: ' + msg);
|
||||||
PDFJS.LogManager.notify('info', msg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Non-fatal warnings that should trigger the fallback UI.
|
// Non-fatal warnings.
|
||||||
function warn(msg) {
|
function warn(msg) {
|
||||||
if (verbosity >= WARNINGS) {
|
if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.warnings) {
|
||||||
log('Warning: ' + msg);
|
log('Warning: ' + msg);
|
||||||
PDFJS.LogManager.notify('warn', msg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,15 +216,10 @@ function error(msg) {
|
||||||
log('Error: ' + msg);
|
log('Error: ' + msg);
|
||||||
}
|
}
|
||||||
log(backtrace());
|
log(backtrace());
|
||||||
PDFJS.LogManager.notify('error', msg);
|
UnsupportedManager.notify(UNSUPPORTED_FEATURES.unknown);
|
||||||
throw new Error(msg);
|
throw new Error(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Missing features that should trigger the fallback UI.
|
|
||||||
function TODO(what) {
|
|
||||||
warn('TODO: ' + what);
|
|
||||||
}
|
|
||||||
|
|
||||||
function backtrace() {
|
function backtrace() {
|
||||||
try {
|
try {
|
||||||
throw new Error();
|
throw new Error();
|
||||||
|
@ -236,6 +233,31 @@ function assert(cond, msg) {
|
||||||
error(msg);
|
error(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var UNSUPPORTED_FEATURES = PDFJS.UNSUPPORTED_FEATURES = {
|
||||||
|
unknown: 'unknown',
|
||||||
|
forms: 'forms',
|
||||||
|
javaScript: 'javaScript',
|
||||||
|
smask: 'smask',
|
||||||
|
shadingPattern: 'shadingPattern',
|
||||||
|
font: 'font'
|
||||||
|
};
|
||||||
|
|
||||||
|
var UnsupportedManager = PDFJS.UnsupportedManager =
|
||||||
|
(function UnsupportedManagerClosure() {
|
||||||
|
var listeners = [];
|
||||||
|
return {
|
||||||
|
listen: function (cb) {
|
||||||
|
listeners.push(cb);
|
||||||
|
},
|
||||||
|
notify: function (featureId) {
|
||||||
|
warn('Unsupported feature "' + featureId + '"');
|
||||||
|
for (var i = 0, ii = listeners.length; i < ii; i++) {
|
||||||
|
listeners[i](featureId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
// Combines two URLs. The baseUrl shall be absolute URL. If the url is an
|
// Combines two URLs. The baseUrl shall be absolute URL. If the url is an
|
||||||
// absolute URL, it will be returned as is.
|
// absolute URL, it will be returned as is.
|
||||||
function combineUrl(baseUrl, url) {
|
function combineUrl(baseUrl, url) {
|
||||||
|
@ -289,22 +311,6 @@ function assertWellFormed(cond, msg) {
|
||||||
error(msg);
|
error(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
var LogManager = PDFJS.LogManager = (function LogManagerClosure() {
|
|
||||||
var loggers = [];
|
|
||||||
return {
|
|
||||||
addLogger: function logManager_addLogger(logger) {
|
|
||||||
loggers.push(logger);
|
|
||||||
},
|
|
||||||
notify: function(type, message) {
|
|
||||||
for (var i = 0, ii = loggers.length; i < ii; i++) {
|
|
||||||
var logger = loggers[i];
|
|
||||||
if (logger[type])
|
|
||||||
logger[type](message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
function shadow(obj, prop, value) {
|
function shadow(obj, prop, value) {
|
||||||
Object.defineProperty(obj, prop, { value: value,
|
Object.defineProperty(obj, prop, { value: value,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
|
@ -834,6 +840,24 @@ function isPDFFunction(v) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Legacy support for PDFJS Promise implementation.
|
||||||
|
* TODO remove eventually
|
||||||
|
*/
|
||||||
|
var LegacyPromise = PDFJS.LegacyPromise = (function LegacyPromiseClosure() {
|
||||||
|
return function LegacyPromise() {
|
||||||
|
var resolve, reject;
|
||||||
|
var promise = new Promise(function (resolve_, reject_) {
|
||||||
|
resolve = resolve_;
|
||||||
|
reject = reject_;
|
||||||
|
});
|
||||||
|
promise.resolve = resolve;
|
||||||
|
promise.reject = reject;
|
||||||
|
return promise;
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Polyfill for Promises:
|
||||||
* The following promise implementation tries to generally implment the
|
* The following promise implementation tries to generally implment the
|
||||||
* Promise/A+ spec. Some notable differences from other promise libaries are:
|
* Promise/A+ spec. Some notable differences from other promise libaries are:
|
||||||
* - There currently isn't a seperate deferred and promise object.
|
* - There currently isn't a seperate deferred and promise object.
|
||||||
|
@ -842,7 +866,39 @@ function isPDFFunction(v) {
|
||||||
* Based off of the work in:
|
* Based off of the work in:
|
||||||
* https://bugzilla.mozilla.org/show_bug.cgi?id=810490
|
* https://bugzilla.mozilla.org/show_bug.cgi?id=810490
|
||||||
*/
|
*/
|
||||||
var Promise = PDFJS.Promise = (function PromiseClosure() {
|
(function PromiseClosure() {
|
||||||
|
if (globalScope.Promise) {
|
||||||
|
// Promises existing in the DOM/Worker, checking presence of all/resolve
|
||||||
|
if (typeof globalScope.Promise.all !== 'function') {
|
||||||
|
globalScope.Promise.all = function (iterable) {
|
||||||
|
var count = 0, results = [], resolve, reject;
|
||||||
|
var promise = new globalScope.Promise(function (resolve_, reject_) {
|
||||||
|
resolve = resolve_;
|
||||||
|
reject = reject_;
|
||||||
|
});
|
||||||
|
iterable.forEach(function (p, i) {
|
||||||
|
count++;
|
||||||
|
p.then(function (result) {
|
||||||
|
results[i] = result;
|
||||||
|
count--;
|
||||||
|
if (count === 0) {
|
||||||
|
resolve(results);
|
||||||
|
}
|
||||||
|
}, reject);
|
||||||
|
});
|
||||||
|
if (count === 0) {
|
||||||
|
resolve(results);
|
||||||
|
}
|
||||||
|
return promise;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (typeof globalScope.Promise.resolve !== 'function') {
|
||||||
|
globalScope.Promise.resolve = function (x) {
|
||||||
|
return new globalScope.Promise(function (resolve) { resolve(x); });
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var STATUS_PENDING = 0;
|
var STATUS_PENDING = 0;
|
||||||
var STATUS_RESOLVED = 1;
|
var STATUS_RESOLVED = 1;
|
||||||
var STATUS_REJECTED = 2;
|
var STATUS_REJECTED = 2;
|
||||||
|
@ -875,6 +931,8 @@ var Promise = PDFJS.Promise = (function PromiseClosure() {
|
||||||
},
|
},
|
||||||
|
|
||||||
runHandlers: function runHandlers() {
|
runHandlers: function runHandlers() {
|
||||||
|
var RUN_TIMEOUT = 1; // ms
|
||||||
|
var timeoutAt = Date.now() + RUN_TIMEOUT;
|
||||||
while (this.handlers.length > 0) {
|
while (this.handlers.length > 0) {
|
||||||
var handler = this.handlers.shift();
|
var handler = this.handlers.shift();
|
||||||
|
|
||||||
|
@ -900,6 +958,14 @@ var Promise = PDFJS.Promise = (function PromiseClosure() {
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.nextPromise._updateStatus(nextStatus, nextValue);
|
handler.nextPromise._updateStatus(nextStatus, nextValue);
|
||||||
|
if (Date.now() >= timeoutAt) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.handlers.length > 0) {
|
||||||
|
setTimeout(this.runHandlers.bind(this), 0);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.running = false;
|
this.running = false;
|
||||||
|
@ -950,9 +1016,10 @@ var Promise = PDFJS.Promise = (function PromiseClosure() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function Promise() {
|
function Promise(resolver) {
|
||||||
this._status = STATUS_PENDING;
|
this._status = STATUS_PENDING;
|
||||||
this._handlers = [];
|
this._handlers = [];
|
||||||
|
resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Builds a promise that is resolved when all the passed in promises are
|
* Builds a promise that is resolved when all the passed in promises are
|
||||||
|
@ -961,11 +1028,15 @@ var Promise = PDFJS.Promise = (function PromiseClosure() {
|
||||||
* @return {Promise} New dependant promise.
|
* @return {Promise} New dependant promise.
|
||||||
*/
|
*/
|
||||||
Promise.all = function Promise_all(promises) {
|
Promise.all = function Promise_all(promises) {
|
||||||
var deferred = new Promise();
|
var resolveAll, rejectAll;
|
||||||
|
var deferred = new Promise(function (resolve, reject) {
|
||||||
|
resolveAll = resolve;
|
||||||
|
rejectAll = reject;
|
||||||
|
});
|
||||||
var unresolved = promises.length;
|
var unresolved = promises.length;
|
||||||
var results = [];
|
var results = [];
|
||||||
if (unresolved === 0) {
|
if (unresolved === 0) {
|
||||||
deferred.resolve(results);
|
resolveAll(results);
|
||||||
return deferred;
|
return deferred;
|
||||||
}
|
}
|
||||||
function reject(reason) {
|
function reject(reason) {
|
||||||
|
@ -973,7 +1044,7 @@ var Promise = PDFJS.Promise = (function PromiseClosure() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
results = [];
|
results = [];
|
||||||
deferred.reject(reason);
|
rejectAll(reason);
|
||||||
}
|
}
|
||||||
for (var i = 0, ii = promises.length; i < ii; ++i) {
|
for (var i = 0, ii = promises.length; i < ii; ++i) {
|
||||||
var promise = promises[i];
|
var promise = promises[i];
|
||||||
|
@ -985,7 +1056,7 @@ var Promise = PDFJS.Promise = (function PromiseClosure() {
|
||||||
results[i] = value;
|
results[i] = value;
|
||||||
unresolved--;
|
unresolved--;
|
||||||
if (unresolved === 0)
|
if (unresolved === 0)
|
||||||
deferred.resolve(results);
|
resolveAll(results);
|
||||||
};
|
};
|
||||||
})(i);
|
})(i);
|
||||||
if (Promise.isPromise(promise)) {
|
if (Promise.isPromise(promise)) {
|
||||||
|
@ -1004,6 +1075,14 @@ var Promise = PDFJS.Promise = (function PromiseClosure() {
|
||||||
Promise.isPromise = function Promise_isPromise(value) {
|
Promise.isPromise = function Promise_isPromise(value) {
|
||||||
return value && typeof value.then === 'function';
|
return value && typeof value.then === 'function';
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Creates resolved promise
|
||||||
|
* @param x resolve value
|
||||||
|
* @returns {Promise}
|
||||||
|
*/
|
||||||
|
Promise.resolve = function Promise_resolve(x) {
|
||||||
|
return new Promise(function (resolve) { resolve(x); });
|
||||||
|
};
|
||||||
|
|
||||||
Promise.prototype = {
|
Promise.prototype = {
|
||||||
_status: null,
|
_status: null,
|
||||||
|
@ -1035,24 +1114,19 @@ var Promise = PDFJS.Promise = (function PromiseClosure() {
|
||||||
HandlerManager.scheduleHandlers(this);
|
HandlerManager.scheduleHandlers(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
get isResolved() {
|
_resolve: function Promise_resolve(value) {
|
||||||
return this._status === STATUS_RESOLVED;
|
|
||||||
},
|
|
||||||
|
|
||||||
get isRejected() {
|
|
||||||
return this._status === STATUS_REJECTED;
|
|
||||||
},
|
|
||||||
|
|
||||||
resolve: function Promise_resolve(value) {
|
|
||||||
this._updateStatus(STATUS_RESOLVED, value);
|
this._updateStatus(STATUS_RESOLVED, value);
|
||||||
},
|
},
|
||||||
|
|
||||||
reject: function Promise_reject(reason) {
|
_reject: function Promise_reject(reason) {
|
||||||
this._updateStatus(STATUS_REJECTED, reason);
|
this._updateStatus(STATUS_REJECTED, reason);
|
||||||
},
|
},
|
||||||
|
|
||||||
then: function Promise_then(onResolve, onReject) {
|
then: function Promise_then(onResolve, onReject) {
|
||||||
var nextPromise = new Promise();
|
var nextPromise = new Promise(function (resolve, reject) {
|
||||||
|
this.resolve = reject;
|
||||||
|
this.reject = reject;
|
||||||
|
});
|
||||||
this._handlers.push({
|
this._handlers.push({
|
||||||
thisPromise: this,
|
thisPromise: this,
|
||||||
onResolve: onResolve,
|
onResolve: onResolve,
|
||||||
|
@ -1064,7 +1138,7 @@ var Promise = PDFJS.Promise = (function PromiseClosure() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return Promise;
|
globalScope.Promise = Promise;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
var StatTimer = (function StatTimerClosure() {
|
var StatTimer = (function StatTimerClosure() {
|
||||||
|
@ -1178,8 +1252,8 @@ function MessageHandler(name, comObj) {
|
||||||
log.apply(null, data);
|
log.apply(null, data);
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
ah['_warn'] = [function ah_Warn(data) {
|
ah['_unsupported_feature'] = [function ah_unsupportedFeature(data) {
|
||||||
warn(data);
|
UnsupportedManager.notify(data);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
comObj.onmessage = function messageHandlerComObjOnMessage(event) {
|
comObj.onmessage = function messageHandlerComObjOnMessage(event) {
|
||||||
|
@ -1196,7 +1270,12 @@ function MessageHandler(name, comObj) {
|
||||||
} else if (data.action in ah) {
|
} else if (data.action in ah) {
|
||||||
var action = ah[data.action];
|
var action = ah[data.action];
|
||||||
if (data.callbackId) {
|
if (data.callbackId) {
|
||||||
var promise = new Promise();
|
var deferred = {};
|
||||||
|
var promise = new Promise(function (resolve, reject) {
|
||||||
|
deferred.resolve = resolve;
|
||||||
|
deferred.reject = reject;
|
||||||
|
});
|
||||||
|
deferred.promise = promise;
|
||||||
promise.then(function(resolvedData) {
|
promise.then(function(resolvedData) {
|
||||||
comObj.postMessage({
|
comObj.postMessage({
|
||||||
isReply: true,
|
isReply: true,
|
||||||
|
@ -1204,7 +1283,7 @@ function MessageHandler(name, comObj) {
|
||||||
data: resolvedData
|
data: resolvedData
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
action[0].call(action[1], data.data, promise);
|
action[0].call(action[1], data.data, deferred);
|
||||||
} else {
|
} else {
|
||||||
action[0].call(action[1], data.data);
|
action[0].call(action[1], data.data);
|
||||||
}
|
}
|
||||||
|
@ -1876,8 +1955,8 @@ var DeviceCmykCS = (function DeviceCmykCSClosure() {
|
||||||
var CalGrayCS = (function CalGrayCSClosure() {
|
var CalGrayCS = (function CalGrayCSClosure() {
|
||||||
function CalGrayCS(whitePoint, blackPoint, gamma) {
|
function CalGrayCS(whitePoint, blackPoint, gamma) {
|
||||||
this.name = 'CalGray';
|
this.name = 'CalGray';
|
||||||
this.numComps = 3;
|
this.numComps = 1;
|
||||||
this.defaultColor = new Float32Array([0, 0, 0]);
|
this.defaultColor = new Float32Array([0]);
|
||||||
|
|
||||||
if (!whitePoint) {
|
if (!whitePoint) {
|
||||||
error('WhitePoint missing - required for color space CalGray');
|
error('WhitePoint missing - required for color space CalGray');
|
||||||
|
@ -1908,7 +1987,7 @@ var CalGrayCS = (function CalGrayCSClosure() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
|
if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
|
||||||
TODO(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB +
|
warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB +
|
||||||
', ZB: ' + this.ZB + ', only default values are supported.');
|
', ZB: ' + this.ZB + ', only default values are supported.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1919,6 +1998,33 @@ var CalGrayCS = (function CalGrayCSClosure() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
|
||||||
|
// A represents a gray component of a calibrated gray space.
|
||||||
|
// A <---> AG in the spec
|
||||||
|
var A = src[srcOffset] * scale;
|
||||||
|
var AG = Math.pow(A, cs.G);
|
||||||
|
|
||||||
|
// Computes intermediate variables M, L, N as per spec.
|
||||||
|
// Except if other than default BlackPoint values are used.
|
||||||
|
var M = cs.XW * AG;
|
||||||
|
var L = cs.YW * AG;
|
||||||
|
var N = cs.ZW * AG;
|
||||||
|
|
||||||
|
// Decode XYZ, as per spec.
|
||||||
|
var X = M;
|
||||||
|
var Y = L;
|
||||||
|
var Z = N;
|
||||||
|
|
||||||
|
// http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html, Ch 4.
|
||||||
|
// This yields values in range [0, 100].
|
||||||
|
var Lstar = Math.max(116 * Math.pow(Y, 1 / 3) - 16, 0);
|
||||||
|
|
||||||
|
// Convert values to rgb range [0, 255].
|
||||||
|
dest[destOffset] = Lstar * 255 / 100;
|
||||||
|
dest[destOffset + 1] = Lstar * 255 / 100;
|
||||||
|
dest[destOffset + 2] = Lstar * 255 / 100;
|
||||||
|
}
|
||||||
|
|
||||||
CalGrayCS.prototype = {
|
CalGrayCS.prototype = {
|
||||||
getRgb: function CalGrayCS_getRgb(src, srcOffset) {
|
getRgb: function CalGrayCS_getRgb(src, srcOffset) {
|
||||||
var rgb = new Uint8Array(3);
|
var rgb = new Uint8Array(3);
|
||||||
|
@ -1927,41 +2033,16 @@ var CalGrayCS = (function CalGrayCSClosure() {
|
||||||
},
|
},
|
||||||
getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset,
|
getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset,
|
||||||
dest, destOffset) {
|
dest, destOffset) {
|
||||||
// A represents a gray component of a calibrated gray space.
|
convertToRgb(this, src, srcOffset, dest, destOffset, 1);
|
||||||
// A <---> AG in the spec
|
|
||||||
var A = src[srcOffset];
|
|
||||||
var AG = Math.pow(A, this.G);
|
|
||||||
|
|
||||||
// Computes intermediate variables M, L, N as per spec.
|
|
||||||
// Except if other than default BlackPoint values are used.
|
|
||||||
var M = this.XW * AG;
|
|
||||||
var L = this.YW * AG;
|
|
||||||
var N = this.ZW * AG;
|
|
||||||
|
|
||||||
// Decode XYZ, as per spec.
|
|
||||||
var X = M;
|
|
||||||
var Y = L;
|
|
||||||
var Z = N;
|
|
||||||
|
|
||||||
// http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html, Ch 4.
|
|
||||||
// This yields values in range [0, 100].
|
|
||||||
var Lstar = Math.max(116 * Math.pow(Y, 1 / 3) - 16, 0);
|
|
||||||
|
|
||||||
// Convert values to rgb range [0, 255].
|
|
||||||
dest[destOffset] = Lstar * 255 / 100;
|
|
||||||
dest[destOffset + 1] = Lstar * 255 / 100;
|
|
||||||
dest[destOffset + 2] = Lstar * 255 / 100;
|
|
||||||
},
|
},
|
||||||
getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count,
|
getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count,
|
||||||
dest, destOffset, bits) {
|
dest, destOffset, bits) {
|
||||||
// TODO: This part is copied from DeviceGray. Make this utility function.
|
var scale = 1 / ((1 << bits) - 1);
|
||||||
var scale = 255 / ((1 << bits) - 1);
|
|
||||||
var j = srcOffset, q = destOffset;
|
|
||||||
for (var i = 0; i < count; ++i) {
|
for (var i = 0; i < count; ++i) {
|
||||||
var c = (scale * src[j++]) | 0;
|
convertToRgb(this, src, srcOffset, dest, destOffset, scale);
|
||||||
dest[q++] = c;
|
srcOffset += 1;
|
||||||
dest[q++] = c;
|
destOffset += 3;
|
||||||
dest[q++] = c;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getOutputLength: function CalGrayCS_getOutputLength(inputLength) {
|
getOutputLength: function CalGrayCS_getOutputLength(inputLength) {
|
||||||
|
@ -2155,7 +2236,7 @@ var Pattern = (function PatternClosure() {
|
||||||
// Both radial and axial shadings are handled by RadialAxial shading.
|
// Both radial and axial shadings are handled by RadialAxial shading.
|
||||||
return new Shadings.RadialAxial(dict, matrix, xref, res);
|
return new Shadings.RadialAxial(dict, matrix, xref, res);
|
||||||
default:
|
default:
|
||||||
TODO('Unsupported shading type: ' + type);
|
UnsupportedManager.notify(UNSUPPORTED_FEATURES.shadingPattern);
|
||||||
return new Shadings.Dummy();
|
return new Shadings.Dummy();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -2415,7 +2496,7 @@ var TilingPattern = (function TilingPatternClosure() {
|
||||||
var commonObjs = this.commonObjs;
|
var commonObjs = this.commonObjs;
|
||||||
var ctx = this.ctx;
|
var ctx = this.ctx;
|
||||||
|
|
||||||
TODO('TilingType: ' + tilingType);
|
info('TilingType: ' + tilingType);
|
||||||
|
|
||||||
var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
|
var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
|
||||||
|
|
||||||
|
@ -2628,7 +2709,7 @@ var PDFFunction = (function PDFFunctionClosure() {
|
||||||
if (order !== 1) {
|
if (order !== 1) {
|
||||||
// No description how cubic spline interpolation works in PDF32000:2008
|
// No description how cubic spline interpolation works in PDF32000:2008
|
||||||
// As in poppler, ignoring order, linear interpolation may work as good
|
// As in poppler, ignoring order, linear interpolation may work as good
|
||||||
TODO('No support for cubic spline interpolation: ' + order);
|
info('No support for cubic spline interpolation: ' + order);
|
||||||
}
|
}
|
||||||
|
|
||||||
var encode = dict.get('Encode');
|
var encode = dict.get('Encode');
|
||||||
|
@ -3521,7 +3602,7 @@ var Annotation = (function AnnotationClosure() {
|
||||||
},
|
},
|
||||||
|
|
||||||
loadResources: function(keys) {
|
loadResources: function(keys) {
|
||||||
var promise = new Promise();
|
var promise = new LegacyPromise();
|
||||||
this.appearance.dict.getAsync('Resources').then(function(resources) {
|
this.appearance.dict.getAsync('Resources').then(function(resources) {
|
||||||
if (!resources) {
|
if (!resources) {
|
||||||
promise.resolve();
|
promise.resolve();
|
||||||
|
@ -3540,7 +3621,7 @@ var Annotation = (function AnnotationClosure() {
|
||||||
|
|
||||||
getOperatorList: function Annotation_getToOperatorList(evaluator) {
|
getOperatorList: function Annotation_getToOperatorList(evaluator) {
|
||||||
|
|
||||||
var promise = new Promise();
|
var promise = new LegacyPromise();
|
||||||
|
|
||||||
if (!this.appearance) {
|
if (!this.appearance) {
|
||||||
promise.resolve(new OperatorList());
|
promise.resolve(new OperatorList());
|
||||||
|
@ -3646,7 +3727,7 @@ var Annotation = (function AnnotationClosure() {
|
||||||
if (annotation.isViewable()) {
|
if (annotation.isViewable()) {
|
||||||
return annotation;
|
return annotation;
|
||||||
} else {
|
} else {
|
||||||
TODO('unimplemented annotation type: ' + subtype);
|
warn('unimplemented annotation type: ' + subtype);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3657,7 +3738,7 @@ var Annotation = (function AnnotationClosure() {
|
||||||
annotationsReadyPromise.reject(e);
|
annotationsReadyPromise.reject(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
var annotationsReadyPromise = new Promise();
|
var annotationsReadyPromise = new LegacyPromise();
|
||||||
|
|
||||||
var annotationPromises = [];
|
var annotationPromises = [];
|
||||||
for (var i = 0, n = annotations.length; i < n; ++i) {
|
for (var i = 0, n = annotations.length; i < n; ++i) {
|
||||||
|
@ -3738,7 +3819,7 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
|
||||||
Util.inherit(WidgetAnnotation, Annotation, {
|
Util.inherit(WidgetAnnotation, Annotation, {
|
||||||
isViewable: function WidgetAnnotation_isViewable() {
|
isViewable: function WidgetAnnotation_isViewable() {
|
||||||
if (this.data.fieldType === 'Sig') {
|
if (this.data.fieldType === 'Sig') {
|
||||||
TODO('unimplemented annotation type: Widget signature');
|
warn('unimplemented annotation type: Widget signature');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3819,7 +3900,7 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
|
||||||
return Annotation.prototype.getOperatorList.call(this, evaluator);
|
return Annotation.prototype.getOperatorList.call(this, evaluator);
|
||||||
}
|
}
|
||||||
|
|
||||||
var promise = new Promise();
|
var promise = new LegacyPromise();
|
||||||
var opList = new OperatorList();
|
var opList = new OperatorList();
|
||||||
var data = this.data;
|
var data = this.data;
|
||||||
|
|
||||||
|
@ -3896,7 +3977,7 @@ var TextAnnotation = (function TextAnnotationClosure() {
|
||||||
Util.inherit(TextAnnotation, Annotation, {
|
Util.inherit(TextAnnotation, Annotation, {
|
||||||
|
|
||||||
getOperatorList: function TextAnnotation_getOperatorList(evaluator) {
|
getOperatorList: function TextAnnotation_getOperatorList(evaluator) {
|
||||||
var promise = new Promise();
|
var promise = new LegacyPromise();
|
||||||
promise.resolve(new OperatorList());
|
promise.resolve(new OperatorList());
|
||||||
return promise;
|
return promise;
|
||||||
},
|
},
|
||||||
|
@ -4023,7 +4104,7 @@ var LinkAnnotation = (function LinkAnnotationClosure() {
|
||||||
} else if (linkType === 'Named') {
|
} else if (linkType === 'Named') {
|
||||||
data.action = action.get('N').name;
|
data.action = action.get('N').name;
|
||||||
} else {
|
} else {
|
||||||
TODO('unrecognized link type: ' + linkType);
|
warn('unrecognized link type: ' + linkType);
|
||||||
}
|
}
|
||||||
} else if (dict.has('Dest')) {
|
} else if (dict.has('Dest')) {
|
||||||
// simple destination link
|
// simple destination link
|
||||||
|
@ -4148,6 +4229,18 @@ PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
|
||||||
*/
|
*/
|
||||||
PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ?
|
PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ?
|
||||||
true : PDFJS.postMessageTransfers;
|
true : PDFJS.postMessageTransfers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controls the logging level.
|
||||||
|
* The constants from PDFJS.VERBOSITY_LEVELS should be used:
|
||||||
|
* - errors
|
||||||
|
* - warnings [default]
|
||||||
|
* - infos
|
||||||
|
* @var {Number}
|
||||||
|
*/
|
||||||
|
PDFJS.verbosity = PDFJS.verbosity === undefined ?
|
||||||
|
PDFJS.VERBOSITY_LEVELS.warnings : PDFJS.verbosity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the main entry point for loading a PDF and interacting with it.
|
* This is the main entry point for loading a PDF and interacting with it.
|
||||||
* NOTE: If a URL is used to fetch the PDF data a standard XMLHttpRequest(XHR)
|
* NOTE: If a URL is used to fetch the PDF data a standard XMLHttpRequest(XHR)
|
||||||
|
@ -4204,8 +4297,8 @@ PDFJS.getDocument = function getDocument(source,
|
||||||
params[key] = source[key];
|
params[key] = source[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
workerInitializedPromise = new PDFJS.Promise();
|
workerInitializedPromise = new PDFJS.LegacyPromise();
|
||||||
workerReadyPromise = new PDFJS.Promise();
|
workerReadyPromise = new PDFJS.LegacyPromise();
|
||||||
transport = new WorkerTransport(workerInitializedPromise,
|
transport = new WorkerTransport(workerInitializedPromise,
|
||||||
workerReadyPromise, pdfDataRangeTransport, progressCallback);
|
workerReadyPromise, pdfDataRangeTransport, progressCallback);
|
||||||
workerInitializedPromise.then(function transportInitialized() {
|
workerInitializedPromise.then(function transportInitialized() {
|
||||||
|
@ -4273,7 +4366,7 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
|
||||||
* JavaScript strings in the name tree.
|
* JavaScript strings in the name tree.
|
||||||
*/
|
*/
|
||||||
getJavaScript: function PDFDocumentProxy_getJavaScript() {
|
getJavaScript: function PDFDocumentProxy_getJavaScript() {
|
||||||
var promise = new PDFJS.Promise();
|
var promise = new PDFJS.LegacyPromise();
|
||||||
var js = this.pdfInfo.javaScript;
|
var js = this.pdfInfo.javaScript;
|
||||||
promise.resolve(js);
|
promise.resolve(js);
|
||||||
return promise;
|
return promise;
|
||||||
|
@ -4294,7 +4387,7 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
|
||||||
* ].
|
* ].
|
||||||
*/
|
*/
|
||||||
getOutline: function PDFDocumentProxy_getOutline() {
|
getOutline: function PDFDocumentProxy_getOutline() {
|
||||||
var promise = new PDFJS.Promise();
|
var promise = new PDFJS.LegacyPromise();
|
||||||
var outline = this.pdfInfo.outline;
|
var outline = this.pdfInfo.outline;
|
||||||
promise.resolve(outline);
|
promise.resolve(outline);
|
||||||
return promise;
|
return promise;
|
||||||
|
@ -4306,7 +4399,7 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
|
||||||
* {Metadata} object with information from the metadata section of the PDF.
|
* {Metadata} object with information from the metadata section of the PDF.
|
||||||
*/
|
*/
|
||||||
getMetadata: function PDFDocumentProxy_getMetadata() {
|
getMetadata: function PDFDocumentProxy_getMetadata() {
|
||||||
var promise = new PDFJS.Promise();
|
var promise = new PDFJS.LegacyPromise();
|
||||||
var info = this.pdfInfo.info;
|
var info = this.pdfInfo.info;
|
||||||
var metadata = this.pdfInfo.metadata;
|
var metadata = this.pdfInfo.metadata;
|
||||||
promise.resolve({
|
promise.resolve({
|
||||||
|
@ -4316,7 +4409,7 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
|
||||||
return promise;
|
return promise;
|
||||||
},
|
},
|
||||||
isEncrypted: function PDFDocumentProxy_isEncrypted() {
|
isEncrypted: function PDFDocumentProxy_isEncrypted() {
|
||||||
var promise = new PDFJS.Promise();
|
var promise = new PDFJS.LegacyPromise();
|
||||||
promise.resolve(this.pdfInfo.encrypted);
|
promise.resolve(this.pdfInfo.encrypted);
|
||||||
return promise;
|
return promise;
|
||||||
},
|
},
|
||||||
|
@ -4325,7 +4418,7 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
|
||||||
* the raw data from the PDF.
|
* the raw data from the PDF.
|
||||||
*/
|
*/
|
||||||
getData: function PDFDocumentProxy_getData() {
|
getData: function PDFDocumentProxy_getData() {
|
||||||
var promise = new PDFJS.Promise();
|
var promise = new PDFJS.LegacyPromise();
|
||||||
this.transport.getData(promise);
|
this.transport.getData(promise);
|
||||||
return promise;
|
return promise;
|
||||||
},
|
},
|
||||||
|
@ -4406,7 +4499,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
||||||
if (this.annotationsPromise)
|
if (this.annotationsPromise)
|
||||||
return this.annotationsPromise;
|
return this.annotationsPromise;
|
||||||
|
|
||||||
var promise = new PDFJS.Promise();
|
var promise = new PDFJS.LegacyPromise();
|
||||||
this.annotationsPromise = promise;
|
this.annotationsPromise = promise;
|
||||||
this.transport.getAnnotations(this.pageInfo.pageIndex);
|
this.transport.getAnnotations(this.pageInfo.pageIndex);
|
||||||
return promise;
|
return promise;
|
||||||
|
@ -4440,7 +4533,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
||||||
// requested before. Make the request and create the promise.
|
// requested before. Make the request and create the promise.
|
||||||
if (!this.displayReadyPromise) {
|
if (!this.displayReadyPromise) {
|
||||||
this.receivingOperatorList = true;
|
this.receivingOperatorList = true;
|
||||||
this.displayReadyPromise = new Promise();
|
this.displayReadyPromise = new LegacyPromise();
|
||||||
this.operatorList = {
|
this.operatorList = {
|
||||||
fnArray: [],
|
fnArray: [],
|
||||||
argsArray: [],
|
argsArray: [],
|
||||||
|
@ -4487,9 +4580,9 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
||||||
self._tryDestroy();
|
self._tryDestroy();
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
renderTask.reject(error);
|
renderTask.promise.reject(error);
|
||||||
} else {
|
} else {
|
||||||
renderTask.resolve();
|
renderTask.promise.resolve();
|
||||||
}
|
}
|
||||||
stats.timeEnd('Rendering');
|
stats.timeEnd('Rendering');
|
||||||
stats.timeEnd('Overall');
|
stats.timeEnd('Overall');
|
||||||
|
@ -4502,7 +4595,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
||||||
* content from the page.
|
* content from the page.
|
||||||
*/
|
*/
|
||||||
getTextContent: function PDFPageProxy_getTextContent() {
|
getTextContent: function PDFPageProxy_getTextContent() {
|
||||||
var promise = new PDFJS.Promise();
|
var promise = new PDFJS.LegacyPromise();
|
||||||
this.transport.messageHandler.send('GetTextContent', {
|
this.transport.messageHandler.send('GetTextContent', {
|
||||||
pageIndex: this.pageNumber - 1
|
pageIndex: this.pageNumber - 1
|
||||||
},
|
},
|
||||||
|
@ -4516,7 +4609,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
||||||
* Stub for future feature.
|
* Stub for future feature.
|
||||||
*/
|
*/
|
||||||
getOperationList: function PDFPageProxy_getOperationList() {
|
getOperationList: function PDFPageProxy_getOperationList() {
|
||||||
var promise = new PDFJS.Promise();
|
var promise = new PDFJS.LegacyPromise();
|
||||||
var operationList = { // not implemented
|
var operationList = { // not implemented
|
||||||
dependencyFontsID: null,
|
dependencyFontsID: null,
|
||||||
operatorList: null
|
operatorList: null
|
||||||
|
@ -4668,7 +4761,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
||||||
|
|
||||||
loadFakeWorkerFiles: function WorkerTransport_loadFakeWorkerFiles() {
|
loadFakeWorkerFiles: function WorkerTransport_loadFakeWorkerFiles() {
|
||||||
if (!PDFJS.fakeWorkerFilesLoadedPromise) {
|
if (!PDFJS.fakeWorkerFilesLoadedPromise) {
|
||||||
PDFJS.fakeWorkerFilesLoadedPromise = new Promise();
|
PDFJS.fakeWorkerFilesLoadedPromise = new LegacyPromise();
|
||||||
// In the developer build load worker_loader which in turn loads all the
|
// In the developer build load worker_loader which in turn loads all the
|
||||||
// other files and resolves the promise. In production only the
|
// other files and resolves the promise. In production only the
|
||||||
// pdf.worker.js file is needed.
|
// pdf.worker.js file is needed.
|
||||||
|
@ -4873,7 +4966,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
||||||
error(data.error);
|
error(data.error);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
messageHandler.on('JpegDecode', function(data, promise) {
|
messageHandler.on('JpegDecode', function(data, deferred) {
|
||||||
var imageUrl = data[0];
|
var imageUrl = data[0];
|
||||||
var components = data[1];
|
var components = data[1];
|
||||||
if (components != 3 && components != 1)
|
if (components != 3 && components != 1)
|
||||||
|
@ -4902,7 +4995,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
||||||
buf[j] = data[i];
|
buf[j] = data[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
promise.resolve({ data: buf, width: width, height: height});
|
deferred.resolve({ data: buf, width: width, height: height});
|
||||||
}).bind(this);
|
}).bind(this);
|
||||||
img.src = imageUrl;
|
img.src = imageUrl;
|
||||||
});
|
});
|
||||||
|
@ -4915,7 +5008,8 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
||||||
source: source,
|
source: source,
|
||||||
disableRange: PDFJS.disableRange,
|
disableRange: PDFJS.disableRange,
|
||||||
maxImageSize: PDFJS.maxImageSize,
|
maxImageSize: PDFJS.maxImageSize,
|
||||||
disableFontFace: PDFJS.disableFontFace
|
disableFontFace: PDFJS.disableFontFace,
|
||||||
|
verbosity: PDFJS.verbosity
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -4926,7 +5020,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
||||||
},
|
},
|
||||||
|
|
||||||
dataLoaded: function WorkerTransport_dataLoaded() {
|
dataLoaded: function WorkerTransport_dataLoaded() {
|
||||||
var promise = new PDFJS.Promise();
|
var promise = new PDFJS.LegacyPromise();
|
||||||
this.messageHandler.send('DataLoaded', null, function(args) {
|
this.messageHandler.send('DataLoaded', null, function(args) {
|
||||||
promise.resolve(args);
|
promise.resolve(args);
|
||||||
});
|
});
|
||||||
|
@ -4937,14 +5031,14 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
||||||
var pageIndex = pageNumber - 1;
|
var pageIndex = pageNumber - 1;
|
||||||
if (pageIndex in this.pagePromises)
|
if (pageIndex in this.pagePromises)
|
||||||
return this.pagePromises[pageIndex];
|
return this.pagePromises[pageIndex];
|
||||||
var promise = new PDFJS.Promise('Page ' + pageNumber);
|
var promise = new PDFJS.LegacyPromise();
|
||||||
this.pagePromises[pageIndex] = promise;
|
this.pagePromises[pageIndex] = promise;
|
||||||
this.messageHandler.send('GetPageRequest', { pageIndex: pageIndex });
|
this.messageHandler.send('GetPageRequest', { pageIndex: pageIndex });
|
||||||
return promise;
|
return promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
|
getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
|
||||||
var promise = new PDFJS.Promise();
|
var promise = new PDFJS.LegacyPromise();
|
||||||
this.messageHandler.send('GetPageIndex', { ref: ref },
|
this.messageHandler.send('GetPageIndex', { ref: ref },
|
||||||
function (pageIndex) {
|
function (pageIndex) {
|
||||||
promise.resolve(pageIndex);
|
promise.resolve(pageIndex);
|
||||||
|
@ -4959,7 +5053,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
||||||
},
|
},
|
||||||
|
|
||||||
getDestinations: function WorkerTransport_getDestinations() {
|
getDestinations: function WorkerTransport_getDestinations() {
|
||||||
var promise = new PDFJS.Promise();
|
var promise = new PDFJS.LegacyPromise();
|
||||||
this.messageHandler.send('GetDestinations', null,
|
this.messageHandler.send('GetDestinations', null,
|
||||||
function transportDestinations(destinations) {
|
function transportDestinations(destinations) {
|
||||||
promise.resolve(destinations);
|
promise.resolve(destinations);
|
||||||
|
@ -5008,7 +5102,7 @@ var PDFObjects = (function PDFObjectsClosure() {
|
||||||
return this.objs[objId];
|
return this.objs[objId];
|
||||||
|
|
||||||
var obj = {
|
var obj = {
|
||||||
promise: new Promise(objId),
|
promise: new LegacyPromise(),
|
||||||
data: null,
|
data: null,
|
||||||
resolved: false
|
resolved: false
|
||||||
};
|
};
|
||||||
|
@ -5089,17 +5183,13 @@ var PDFObjects = (function PDFObjectsClosure() {
|
||||||
};
|
};
|
||||||
return PDFObjects;
|
return PDFObjects;
|
||||||
})();
|
})();
|
||||||
/*
|
|
||||||
* RenderTask is basically a promise but adds a cancel function to terminate it.
|
|
||||||
*/
|
|
||||||
var RenderTask = (function RenderTaskClosure() {
|
var RenderTask = (function RenderTaskClosure() {
|
||||||
function RenderTask(internalRenderTask) {
|
function RenderTask(internalRenderTask) {
|
||||||
this.internalRenderTask = internalRenderTask;
|
this.internalRenderTask = internalRenderTask;
|
||||||
Promise.call(this);
|
this.promise = new PDFJS.LegacyPromise();
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderTask.prototype = Object.create(Promise.prototype);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel the rendering task. If the task is curently rendering it will not be
|
* Cancel the rendering task. If the task is curently rendering it will not be
|
||||||
* cancelled until graphics pauses with a timeout. The promise that this
|
* cancelled until graphics pauses with a timeout. The promise that this
|
||||||
|
@ -5782,6 +5872,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||||
var commonObjs = this.commonObjs;
|
var commonObjs = this.commonObjs;
|
||||||
var objs = this.objs;
|
var objs = this.objs;
|
||||||
var fnId;
|
var fnId;
|
||||||
|
var deferred = Promise.resolve();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (stepper && i === stepper.nextBreakPoint) {
|
if (stepper && i === stepper.nextBreakPoint) {
|
||||||
|
@ -5823,7 +5914,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||||
// to continue exeution after a short delay.
|
// to continue exeution after a short delay.
|
||||||
// However, this is only possible if a 'continueCallback' is passed in.
|
// However, this is only possible if a 'continueCallback' is passed in.
|
||||||
if (continueCallback && Date.now() > endTime) {
|
if (continueCallback && Date.now() > endTime) {
|
||||||
setTimeout(continueCallback, 0);
|
deferred.then(continueCallback);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6734,7 +6825,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||||
// TODO knockout - supposedly possible with the clever use of compositing
|
// TODO knockout - supposedly possible with the clever use of compositing
|
||||||
// modes.
|
// modes.
|
||||||
if (group.knockout) {
|
if (group.knockout) {
|
||||||
TODO('Support knockout groups.');
|
warn('Knockout groups not supported.');
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentTransform = currentCtx.mozCurrentTransform;
|
var currentTransform = currentCtx.mozCurrentTransform;
|
||||||
|
|
502
static/pdf.js/pdf.worker.js
vendored
|
@ -17,8 +17,9 @@
|
||||||
/* globals PDFJS, PDFBug, FirefoxCom, Stats, Cache, PDFFindBar, CustomStyle,
|
/* globals PDFJS, PDFBug, FirefoxCom, Stats, Cache, PDFFindBar, CustomStyle,
|
||||||
PDFFindController, ProgressBar, TextLayerBuilder, DownloadManager,
|
PDFFindController, ProgressBar, TextLayerBuilder, DownloadManager,
|
||||||
getFileName, scrollIntoView, getPDFFileNameFromURL, PDFHistory,
|
getFileName, scrollIntoView, getPDFFileNameFromURL, PDFHistory,
|
||||||
Preferences, Settings, PageView, ThumbnailView, noContextMenuHandler,
|
Preferences, ViewHistory, PageView, ThumbnailView,
|
||||||
SecondaryToolbar, PasswordPrompt, PresentationMode, HandTool */
|
noContextMenuHandler, SecondaryToolbar, PasswordPrompt,
|
||||||
|
PresentationMode, HandTool, Promise */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -32,8 +33,8 @@ var VERTICAL_PADDING = 5;
|
||||||
var MAX_AUTO_SCALE = 1.25;
|
var MAX_AUTO_SCALE = 1.25;
|
||||||
var MIN_SCALE = 0.25;
|
var MIN_SCALE = 0.25;
|
||||||
var MAX_SCALE = 4.0;
|
var MAX_SCALE = 4.0;
|
||||||
|
var VIEW_HISTORY_MEMORY = 20;
|
||||||
var IMAGE_DIR = '/static/pdf.js/images/';
|
var IMAGE_DIR = '/static/pdf.js/images/';
|
||||||
var SETTINGS_MEMORY = 20;
|
|
||||||
var SCALE_SELECT_CONTAINER_PADDING = 8;
|
var SCALE_SELECT_CONTAINER_PADDING = 8;
|
||||||
var SCALE_SELECT_PADDING = 22;
|
var SCALE_SELECT_PADDING = 22;
|
||||||
var THUMBNAIL_SCROLL_MARGIN = -19;
|
var THUMBNAIL_SCROLL_MARGIN = -19;
|
||||||
|
@ -323,7 +324,9 @@ var DEFAULT_PREFERENCES = {
|
||||||
var Preferences = (function PreferencesClosure() {
|
var Preferences = (function PreferencesClosure() {
|
||||||
function Preferences() {
|
function Preferences() {
|
||||||
this.prefs = {};
|
this.prefs = {};
|
||||||
|
this.isInitializedPromiseResolved = false;
|
||||||
this.initializedPromise = this.readFromStorage().then(function(prefObj) {
|
this.initializedPromise = this.readFromStorage().then(function(prefObj) {
|
||||||
|
this.isInitializedPromiseResolved = true;
|
||||||
if (prefObj) {
|
if (prefObj) {
|
||||||
this.prefs = prefObj;
|
this.prefs = prefObj;
|
||||||
}
|
}
|
||||||
|
@ -336,19 +339,19 @@ var Preferences = (function PreferencesClosure() {
|
||||||
},
|
},
|
||||||
|
|
||||||
readFromStorage: function Preferences_readFromStorage() {
|
readFromStorage: function Preferences_readFromStorage() {
|
||||||
var readFromStoragePromise = new PDFJS.Promise();
|
var readFromStoragePromise = Promise.resolve();
|
||||||
return readFromStoragePromise;
|
return readFromStoragePromise;
|
||||||
},
|
},
|
||||||
|
|
||||||
reset: function Preferences_reset() {
|
reset: function Preferences_reset() {
|
||||||
if (this.initializedPromise.isResolved) {
|
if (this.isInitializedPromiseResolved) {
|
||||||
this.prefs = {};
|
this.prefs = {};
|
||||||
this.writeToStorage(this.prefs);
|
this.writeToStorage(this.prefs);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
set: function Preferences_set(name, value) {
|
set: function Preferences_set(name, value) {
|
||||||
if (!this.initializedPromise.isResolved) {
|
if (!this.isInitializedPromiseResolved) {
|
||||||
return;
|
return;
|
||||||
} else if (DEFAULT_PREFERENCES[name] === undefined) {
|
} else if (DEFAULT_PREFERENCES[name] === undefined) {
|
||||||
console.error('Preferences_set: \'' + name + '\' is undefined.');
|
console.error('Preferences_set: \'' + name + '\' is undefined.');
|
||||||
|
@ -379,7 +382,7 @@ var Preferences = (function PreferencesClosure() {
|
||||||
if (defaultPref === undefined) {
|
if (defaultPref === undefined) {
|
||||||
console.error('Preferences_get: \'' + name + '\' is undefined.');
|
console.error('Preferences_get: \'' + name + '\' is undefined.');
|
||||||
return;
|
return;
|
||||||
} else if (this.initializedPromise.isResolved) {
|
} else if (this.isInitializedPromiseResolved) {
|
||||||
var pref = this.prefs[name];
|
var pref = this.prefs[name];
|
||||||
|
|
||||||
if (pref !== undefined) {
|
if (pref !== undefined) {
|
||||||
|
@ -401,11 +404,12 @@ Preferences.prototype.writeToStorage = function(prefObj) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Preferences.prototype.readFromStorage = function() {
|
Preferences.prototype.readFromStorage = function() {
|
||||||
var readFromStoragePromise = new PDFJS.Promise();
|
var readFromStoragePromise = new Promise(function (resolve) {
|
||||||
if (isLocalStorageEnabled) {
|
if (isLocalStorageEnabled) {
|
||||||
var readPrefs = JSON.parse(localStorage.getItem('preferences'));
|
var readPrefs = JSON.parse(localStorage.getItem('preferences'));
|
||||||
readFromStoragePromise.resolve(readPrefs);
|
resolve(readPrefs);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
return readFromStoragePromise;
|
return readFromStoragePromise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -614,34 +618,28 @@ var currentPageNumber = 1;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings Manager - This is a utility for saving settings.
|
* View History - This is a utility for saving various view parameters for
|
||||||
|
* recently opened files.
|
||||||
*
|
*
|
||||||
* The way that settings are stored depends on how PDF.js is built,
|
* The way that the view parameters are stored depends on how PDF.js is built,
|
||||||
* for 'node make <flag>' the following cases exist:
|
* for 'node make <flag>' the following cases exist:
|
||||||
* - FIREFOX or MOZCENTRAL - uses about:config.
|
* - FIREFOX or MOZCENTRAL - uses about:config.
|
||||||
* - B2G - uses asyncStorage.
|
* - B2G - uses asyncStorage.
|
||||||
* - GENERIC or CHROME - uses localStorage, if it is available.
|
* - GENERIC or CHROME - uses localStorage, if it is available.
|
||||||
*/
|
*/
|
||||||
var Settings = (function SettingsClosure() {
|
var ViewHistory = (function ViewHistoryClosure() {
|
||||||
var isLocalStorageEnabled = (function localStorageEnabledTest() {
|
function ViewHistory(fingerprint) {
|
||||||
// Feature test as per http://diveintohtml5.info/storage.html
|
|
||||||
// The additional localStorage call is to get around a FF quirk, see
|
|
||||||
// bug #495747 in bugzilla
|
|
||||||
try {
|
|
||||||
return ('localStorage' in window && window['localStorage'] !== null &&
|
|
||||||
localStorage);
|
|
||||||
} catch (e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
function Settings(fingerprint) {
|
|
||||||
this.fingerprint = fingerprint;
|
this.fingerprint = fingerprint;
|
||||||
this.initializedPromise = new PDFJS.Promise();
|
var initializedPromiseResolve;
|
||||||
|
this.isInitializedPromiseResolved = false;
|
||||||
|
this.initializedPromise = new Promise(function (resolve) {
|
||||||
|
initializedPromiseResolve = resolve;
|
||||||
|
});
|
||||||
|
|
||||||
var resolvePromise = (function settingsResolvePromise(db) {
|
var resolvePromise = (function ViewHistoryResolvePromise(db) {
|
||||||
|
this.isInitializedPromiseResolved = true;
|
||||||
this.initialize(db || '{}');
|
this.initialize(db || '{}');
|
||||||
this.initializedPromise.resolve();
|
initializedPromiseResolve();
|
||||||
}).bind(this);
|
}).bind(this);
|
||||||
|
|
||||||
|
|
||||||
|
@ -651,13 +649,13 @@ var Settings = (function SettingsClosure() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.prototype = {
|
ViewHistory.prototype = {
|
||||||
initialize: function settingsInitialize(database) {
|
initialize: function ViewHistory_initialize(database) {
|
||||||
database = JSON.parse(database);
|
database = JSON.parse(database);
|
||||||
if (!('files' in database)) {
|
if (!('files' in database)) {
|
||||||
database.files = [];
|
database.files = [];
|
||||||
}
|
}
|
||||||
if (database.files.length >= SETTINGS_MEMORY) {
|
if (database.files.length >= VIEW_HISTORY_MEMORY) {
|
||||||
database.files.shift();
|
database.files.shift();
|
||||||
}
|
}
|
||||||
var index;
|
var index;
|
||||||
|
@ -675,8 +673,8 @@ var Settings = (function SettingsClosure() {
|
||||||
this.database = database;
|
this.database = database;
|
||||||
},
|
},
|
||||||
|
|
||||||
set: function settingsSet(name, val) {
|
set: function ViewHistory_set(name, val) {
|
||||||
if (!this.initializedPromise.isResolved) {
|
if (!this.isInitializedPromiseResolved) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var file = this.file;
|
var file = this.file;
|
||||||
|
@ -690,15 +688,15 @@ var Settings = (function SettingsClosure() {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
get: function settingsGet(name, defaultValue) {
|
get: function ViewHistory_get(name, defaultValue) {
|
||||||
if (!this.initializedPromise.isResolved) {
|
if (!this.isInitializedPromiseResolved) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
return this.file[name] || defaultValue;
|
return this.file[name] || defaultValue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return Settings;
|
return ViewHistory;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
@ -861,7 +859,7 @@ var PDFFindBar = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* globals PDFFindBar, PDFJS, FindStates, FirefoxCom */
|
/* globals PDFFindBar, PDFJS, FindStates, FirefoxCom, Promise */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a "search" or "find" functionality for the PDF.
|
* Provides a "search" or "find" functionality for the PDF.
|
||||||
|
@ -909,8 +907,6 @@ var PDFFindController = {
|
||||||
|
|
||||||
integratedFind: false,
|
integratedFind: false,
|
||||||
|
|
||||||
firstPagePromise: new PDFJS.Promise(),
|
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
if(typeof PDFFindBar === 'undefined' || PDFFindBar === null) {
|
if(typeof PDFFindBar === 'undefined' || PDFFindBar === null) {
|
||||||
throw 'PDFFindController cannot be initialized ' +
|
throw 'PDFFindController cannot be initialized ' +
|
||||||
|
@ -927,6 +923,9 @@ var PDFFindController = {
|
||||||
'findcasesensitivitychange'
|
'findcasesensitivitychange'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
this.firstPagePromise = new Promise(function (resolve) {
|
||||||
|
this.resolveFirstPage = resolve;
|
||||||
|
}.bind(this));
|
||||||
this.handleEvent = this.handleEvent.bind(this);
|
this.handleEvent = this.handleEvent.bind(this);
|
||||||
|
|
||||||
for (var i = 0; i < events.length; i++) {
|
for (var i = 0; i < events.length; i++) {
|
||||||
|
@ -984,8 +983,11 @@ var PDFFindController = {
|
||||||
this.startedTextExtraction = true;
|
this.startedTextExtraction = true;
|
||||||
|
|
||||||
this.pageContents = [];
|
this.pageContents = [];
|
||||||
|
var extractTextPromisesResolves = [];
|
||||||
for (var i = 0, ii = this.pdfPageSource.pdfDocument.numPages; i < ii; i++) {
|
for (var i = 0, ii = this.pdfPageSource.pdfDocument.numPages; i < ii; i++) {
|
||||||
this.extractTextPromises.push(new PDFJS.Promise());
|
this.extractTextPromises.push(new Promise(function (resolve) {
|
||||||
|
extractTextPromisesResolves.push(resolve);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -1003,7 +1005,7 @@ var PDFFindController = {
|
||||||
// Store the pageContent as a string.
|
// Store the pageContent as a string.
|
||||||
self.pageContents.push(str);
|
self.pageContents.push(str);
|
||||||
|
|
||||||
self.extractTextPromises[pageIndex].resolve(pageIndex);
|
extractTextPromisesResolves[pageIndex](pageIndex);
|
||||||
if ((pageIndex + 1) < self.pdfPageSource.pages.length)
|
if ((pageIndex + 1) < self.pdfPageSource.pages.length)
|
||||||
extractPageText(pageIndex + 1);
|
extractPageText(pageIndex + 1);
|
||||||
}
|
}
|
||||||
|
@ -1572,7 +1574,10 @@ var SecondaryToolbar = {
|
||||||
|
|
||||||
// Attach the event listeners.
|
// Attach the event listeners.
|
||||||
var elements = [
|
var elements = [
|
||||||
|
// Button to toggle the visibility of the secondary toolbar:
|
||||||
{ element: this.toggleButton, handler: this.toggle },
|
{ element: this.toggleButton, handler: this.toggle },
|
||||||
|
// All items within the secondary toolbar
|
||||||
|
// (except for toggleHandTool, hand_tool.js is responsible for it):
|
||||||
{ element: this.presentationModeButton,
|
{ element: this.presentationModeButton,
|
||||||
handler: this.presentationModeClick },
|
handler: this.presentationModeClick },
|
||||||
{ element: this.openFile, handler: this.openFileClick },
|
{ element: this.openFile, handler: this.openFileClick },
|
||||||
|
@ -2158,6 +2163,9 @@ var HandTool = {
|
||||||
this.handTool = new GrabToPan({
|
this.handTool = new GrabToPan({
|
||||||
element: options.container,
|
element: options.container,
|
||||||
onActiveChanged: function(isActive) {
|
onActiveChanged: function(isActive) {
|
||||||
|
if (!toggleHandTool) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
toggleHandTool.title =
|
toggleHandTool.title =
|
||||||
mozL10n.get('hand_tool_disable.title', null, 'Disable hand tool');
|
mozL10n.get('hand_tool_disable.title', null, 'Disable hand tool');
|
||||||
|
@ -2169,9 +2177,11 @@ var HandTool = {
|
||||||
toggleHandTool.firstElementChild.textContent =
|
toggleHandTool.firstElementChild.textContent =
|
||||||
mozL10n.get('hand_tool_enable_label', null, 'Enable hand tool');
|
mozL10n.get('hand_tool_enable_label', null, 'Enable hand tool');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
toggleHandTool.addEventListener('click', this.handTool.toggle, false);
|
if (toggleHandTool) {
|
||||||
|
toggleHandTool.addEventListener('click', this.handTool.toggle, false);
|
||||||
|
}
|
||||||
// TODO: Read global prefs and call this.handTool.activate() if needed.
|
// TODO: Read global prefs and call this.handTool.activate() if needed.
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -2312,19 +2322,37 @@ var PDFView = {
|
||||||
}, true);
|
}, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_setScaleUpdatePages: function pdfView_setScaleUpdatePages(
|
||||||
|
newScale, newValue, resetAutoSettings, noScroll) {
|
||||||
|
this.currentScaleValue = newValue;
|
||||||
|
if (newScale === this.currentScale) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (var i = 0, ii = this.pages.length; i < ii; i++) {
|
||||||
|
this.pages[i].update(newScale);
|
||||||
|
}
|
||||||
|
this.currentScale = newScale;
|
||||||
|
|
||||||
|
if (!noScroll) {
|
||||||
|
this.pages[this.page - 1].scrollIntoView();
|
||||||
|
}
|
||||||
|
var event = document.createEvent('UIEvents');
|
||||||
|
event.initUIEvent('scalechange', false, false, window, 0);
|
||||||
|
event.scale = newScale;
|
||||||
|
event.resetAutoSettings = resetAutoSettings;
|
||||||
|
window.dispatchEvent(event);
|
||||||
|
},
|
||||||
|
|
||||||
setScale: function pdfViewSetScale(value, resetAutoSettings, noScroll) {
|
setScale: function pdfViewSetScale(value, resetAutoSettings, noScroll) {
|
||||||
if (value === 'custom') {
|
if (value === 'custom') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var pages = this.pages;
|
var scale = parseFloat(value);
|
||||||
var currentPage = pages[this.page - 1];
|
|
||||||
var number = parseFloat(value);
|
|
||||||
var scale;
|
|
||||||
|
|
||||||
if (number > 0) {
|
if (scale > 0) {
|
||||||
scale = number;
|
this._setScaleUpdatePages(scale, value, true, noScroll);
|
||||||
resetAutoSettings = true;
|
|
||||||
} else {
|
} else {
|
||||||
|
var currentPage = this.pages[this.page - 1];
|
||||||
if (!currentPage) {
|
if (!currentPage) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2353,28 +2381,8 @@ var PDFView = {
|
||||||
'\' is an unknown zoom value.');
|
'\' is an unknown zoom value.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
this._setScaleUpdatePages(scale, value, resetAutoSettings, noScroll);
|
||||||
this.currentScaleValue = value;
|
|
||||||
|
|
||||||
if (scale === this.currentScale) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (var i = 0, ii = pages.length; i < ii; i++) {
|
|
||||||
pages[i].update(scale);
|
|
||||||
}
|
|
||||||
this.currentScale = scale;
|
|
||||||
|
|
||||||
if (!noScroll) {
|
|
||||||
currentPage.scrollIntoView();
|
|
||||||
}
|
|
||||||
|
|
||||||
var event = document.createEvent('UIEvents');
|
|
||||||
event.initUIEvent('scalechange', false, false, window, 0);
|
|
||||||
event.scale = scale;
|
|
||||||
event.resetAutoSettings = resetAutoSettings;
|
|
||||||
window.dispatchEvent(event);
|
|
||||||
|
|
||||||
if (!number) {
|
|
||||||
selectScaleOption(value);
|
selectScaleOption(value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2681,7 +2689,7 @@ var PDFView = {
|
||||||
).then(null, noData);
|
).then(null, noData);
|
||||||
},
|
},
|
||||||
|
|
||||||
fallback: function pdfViewFallback() {
|
fallback: function pdfViewFallback(featureId) {
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -2842,12 +2850,17 @@ var PDFView = {
|
||||||
|
|
||||||
load: function pdfViewLoad(pdfDocument, scale) {
|
load: function pdfViewLoad(pdfDocument, scale) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var onePageRendered = new PDFJS.Promise();
|
var isOnePageRenderedResolved = false;
|
||||||
|
var resolveOnePageRendered = null;
|
||||||
|
var onePageRendered = new Promise(function (resolve) {
|
||||||
|
resolveOnePageRendered = resolve;
|
||||||
|
});
|
||||||
function bindOnAfterDraw(pageView, thumbnailView) {
|
function bindOnAfterDraw(pageView, thumbnailView) {
|
||||||
// when page is painted, using the image as thumbnail base
|
// when page is painted, using the image as thumbnail base
|
||||||
pageView.onAfterDraw = function pdfViewLoadOnAfterDraw() {
|
pageView.onAfterDraw = function pdfViewLoadOnAfterDraw() {
|
||||||
if (!onePageRendered.isResolved) {
|
if (!isOnePageRenderedResolved) {
|
||||||
onePageRendered.resolve();
|
isOnePageRenderedResolved = true;
|
||||||
|
resolveOnePageRendered();
|
||||||
}
|
}
|
||||||
thumbnailView.setImage(pageView.canvas);
|
thumbnailView.setImage(pageView.canvas);
|
||||||
};
|
};
|
||||||
|
@ -2888,7 +2901,7 @@ var PDFView = {
|
||||||
|
|
||||||
var prefs = PDFView.prefs = new Preferences();
|
var prefs = PDFView.prefs = new Preferences();
|
||||||
PDFView.documentFingerprint = id;
|
PDFView.documentFingerprint = id;
|
||||||
var store = PDFView.store = new Settings(id);
|
var store = PDFView.store = new ViewHistory(id);
|
||||||
|
|
||||||
this.pageRotation = 0;
|
this.pageRotation = 0;
|
||||||
|
|
||||||
|
@ -2896,7 +2909,11 @@ var PDFView = {
|
||||||
var pagesRefMap = this.pagesRefMap = {};
|
var pagesRefMap = this.pagesRefMap = {};
|
||||||
var thumbnails = this.thumbnails = [];
|
var thumbnails = this.thumbnails = [];
|
||||||
|
|
||||||
var pagesPromise = this.pagesPromise = new PDFJS.Promise();
|
var resolvePagesPromise;
|
||||||
|
var pagesPromise = new Promise(function (resolve) {
|
||||||
|
resolvePagesPromise = resolve;
|
||||||
|
});
|
||||||
|
this.pagesPromise = pagesPromise;
|
||||||
|
|
||||||
var firstPagePromise = pdfDocument.getPage(1);
|
var firstPagePromise = pdfDocument.getPage(1);
|
||||||
|
|
||||||
|
@ -2932,13 +2949,13 @@ var PDFView = {
|
||||||
pagesRefMap[refStr] = pageNum;
|
pagesRefMap[refStr] = pageNum;
|
||||||
getPagesLeft--;
|
getPagesLeft--;
|
||||||
if (!getPagesLeft) {
|
if (!getPagesLeft) {
|
||||||
pagesPromise.resolve();
|
resolvePagesPromise();
|
||||||
}
|
}
|
||||||
}.bind(null, pageNum));
|
}.bind(null, pageNum));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// XXX: Printing is semi-broken with auto fetch disabled.
|
// XXX: Printing is semi-broken with auto fetch disabled.
|
||||||
pagesPromise.resolve();
|
resolvePagesPromise();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2948,12 +2965,12 @@ var PDFView = {
|
||||||
|
|
||||||
PDFView.loadingBar.setWidth(container);
|
PDFView.loadingBar.setWidth(container);
|
||||||
|
|
||||||
PDFFindController.firstPagePromise.resolve();
|
PDFFindController.resolveFirstPage();
|
||||||
});
|
});
|
||||||
|
|
||||||
var prefsPromise = prefs.initializedPromise;
|
var prefsPromise = prefs.initializedPromise;
|
||||||
var storePromise = store.initializedPromise;
|
var storePromise = store.initializedPromise;
|
||||||
PDFJS.Promise.all([firstPagePromise, prefsPromise, storePromise]).
|
Promise.all([firstPagePromise, prefsPromise, storePromise]).
|
||||||
then(function() {
|
then(function() {
|
||||||
var showPreviousViewOnLoad = prefs.get('showPreviousViewOnLoad');
|
var showPreviousViewOnLoad = prefs.get('showPreviousViewOnLoad');
|
||||||
var defaultZoomValue = prefs.get('defaultZoomValue');
|
var defaultZoomValue = prefs.get('defaultZoomValue');
|
||||||
|
@ -2987,7 +3004,7 @@ var PDFView = {
|
||||||
pdfDocument.getJavaScript().then(function(javaScript) {
|
pdfDocument.getJavaScript().then(function(javaScript) {
|
||||||
if (javaScript.length) {
|
if (javaScript.length) {
|
||||||
console.warn('Warning: JavaScript is not supported');
|
console.warn('Warning: JavaScript is not supported');
|
||||||
PDFView.fallback();
|
PDFView.fallback(PDFJS.UNSUPPORTED_FEATURES.javaScript);
|
||||||
}
|
}
|
||||||
// Hack to support auto printing.
|
// Hack to support auto printing.
|
||||||
var regex = /\bprint\s*\(/g;
|
var regex = /\bprint\s*\(/g;
|
||||||
|
@ -3013,7 +3030,7 @@ var PDFView = {
|
||||||
// outline depends on destinations and pagesRefMap
|
// outline depends on destinations and pagesRefMap
|
||||||
var promises = [pagesPromise, destinationsPromise,
|
var promises = [pagesPromise, destinationsPromise,
|
||||||
PDFView.animationStartedPromise];
|
PDFView.animationStartedPromise];
|
||||||
PDFJS.Promise.all(promises).then(function() {
|
Promise.all(promises).then(function() {
|
||||||
pdfDocument.getOutline().then(function(outline) {
|
pdfDocument.getOutline().then(function(outline) {
|
||||||
self.outline = new DocumentOutlineView(outline);
|
self.outline = new DocumentOutlineView(outline);
|
||||||
document.getElementById('viewOutline').disabled = !outline;
|
document.getElementById('viewOutline').disabled = !outline;
|
||||||
|
@ -3052,7 +3069,7 @@ var PDFView = {
|
||||||
|
|
||||||
if (info.IsAcroFormPresent) {
|
if (info.IsAcroFormPresent) {
|
||||||
console.warn('Warning: AcroForm/XFA is not supported');
|
console.warn('Warning: AcroForm/XFA is not supported');
|
||||||
PDFView.fallback();
|
PDFView.fallback(PDFJS.UNSUPPORTED_FEATURES.forms);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -3396,7 +3413,7 @@ var PDFView = {
|
||||||
div.removeChild(div.lastChild);
|
div.removeChild(div.lastChild);
|
||||||
},
|
},
|
||||||
|
|
||||||
rotatePages: function pdfViewPageRotation(delta) {
|
rotatePages: function pdfViewRotatePages(delta) {
|
||||||
|
|
||||||
this.pageRotation = (this.pageRotation + 360 + delta) % 360;
|
this.pageRotation = (this.pageRotation + 360 + delta) % 360;
|
||||||
|
|
||||||
|
@ -4045,7 +4062,7 @@ var PageView = function pageView(container, id, scale,
|
||||||
};
|
};
|
||||||
var renderTask = this.renderTask = this.pdfPage.render(renderContext);
|
var renderTask = this.renderTask = this.pdfPage.render(renderContext);
|
||||||
|
|
||||||
this.renderTask.then(
|
this.renderTask.promise.then(
|
||||||
function pdfPageRenderCallback() {
|
function pdfPageRenderCallback() {
|
||||||
pageViewDrawCallback(null);
|
pageViewDrawCallback(null);
|
||||||
},
|
},
|
||||||
|
@ -4105,7 +4122,7 @@ var PageView = function pageView(container, id, scale,
|
||||||
viewport: viewport
|
viewport: viewport
|
||||||
};
|
};
|
||||||
|
|
||||||
pdfPage.render(renderContext).then(function() {
|
pdfPage.render(renderContext).promise.then(function() {
|
||||||
// Tell the printEngine that rendering this canvas/page has finished.
|
// Tell the printEngine that rendering this canvas/page has finished.
|
||||||
obj.done();
|
obj.done();
|
||||||
self.pdfPage.destroy();
|
self.pdfPage.destroy();
|
||||||
|
@ -4147,7 +4164,7 @@ var ThumbnailView = function thumbnailView(container, id, defaultViewport) {
|
||||||
|
|
||||||
this.pdfPage = undefined;
|
this.pdfPage = undefined;
|
||||||
this.viewport = defaultViewport;
|
this.viewport = defaultViewport;
|
||||||
this.pdfPageRotate = defaultViewport.rotate;
|
this.pdfPageRotate = defaultViewport.rotation;
|
||||||
|
|
||||||
this.rotation = 0;
|
this.rotation = 0;
|
||||||
this.pageWidth = this.viewport.width;
|
this.pageWidth = this.viewport.width;
|
||||||
|
@ -4184,20 +4201,16 @@ var ThumbnailView = function thumbnailView(container, id, defaultViewport) {
|
||||||
this.setPdfPage = function thumbnailViewSetPdfPage(pdfPage) {
|
this.setPdfPage = function thumbnailViewSetPdfPage(pdfPage) {
|
||||||
this.pdfPage = pdfPage;
|
this.pdfPage = pdfPage;
|
||||||
this.pdfPageRotate = pdfPage.rotate;
|
this.pdfPageRotate = pdfPage.rotate;
|
||||||
this.viewport = pdfPage.getViewport(1);
|
var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
|
||||||
|
this.viewport = pdfPage.getViewport(1, totalRotation);
|
||||||
this.update();
|
this.update();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.update = function thumbnailViewUpdate(rot) {
|
this.update = function thumbnailViewUpdate(rotation) {
|
||||||
if (!this.pdfPage) {
|
if (rotation !== undefined) {
|
||||||
return;
|
this.rotation = rotation;
|
||||||
}
|
}
|
||||||
|
var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
|
||||||
if (rot !== undefined) {
|
|
||||||
this.rotation = rot;
|
|
||||||
}
|
|
||||||
|
|
||||||
var totalRotation = (this.rotation + this.pdfPage.rotate) % 360;
|
|
||||||
this.viewport = this.viewport.clone({
|
this.viewport = this.viewport.clone({
|
||||||
scale: 1,
|
scale: 1,
|
||||||
rotation: totalRotation
|
rotation: totalRotation
|
||||||
|
@ -4283,7 +4296,7 @@ var ThumbnailView = function thumbnailView(container, id, defaultViewport) {
|
||||||
cont();
|
cont();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.pdfPage.render(renderContext).then(
|
this.pdfPage.render(renderContext).promise.then(
|
||||||
function pdfPageRenderCallback() {
|
function pdfPageRenderCallback() {
|
||||||
self.renderingState = RenderingStates.FINISHED;
|
self.renderingState = RenderingStates.FINISHED;
|
||||||
callback();
|
callback();
|
||||||
|
@ -4297,8 +4310,17 @@ var ThumbnailView = function thumbnailView(container, id, defaultViewport) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setImage = function thumbnailViewSetImage(img) {
|
this.setImage = function thumbnailViewSetImage(img) {
|
||||||
if (this.hasImage || !img)
|
if (!this.pdfPage) {
|
||||||
|
var promise = PDFView.getPage(this.id);
|
||||||
|
promise.then(function(pdfPage) {
|
||||||
|
this.setPdfPage(pdfPage);
|
||||||
|
this.setImage(img);
|
||||||
|
}.bind(this));
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
if (this.hasImage || !img) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.renderingState = RenderingStates.FINISHED;
|
this.renderingState = RenderingStates.FINISHED;
|
||||||
var ctx = this.getPageDrawContext();
|
var ctx = this.getPageDrawContext();
|
||||||
ctx.drawImage(img, 0, 0, img.width, img.height,
|
ctx.drawImage(img, 0, 0, img.width, img.height,
|
||||||
|
@ -4780,6 +4802,10 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
|
||||||
USE_ONLY_CSS_ZOOM = (hashParams['useOnlyCssZoom'] === 'true');
|
USE_ONLY_CSS_ZOOM = (hashParams['useOnlyCssZoom'] === 'true');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ('verbosity' in hashParams) {
|
||||||
|
PDFJS.verbosity = hashParams['verbosity'] | 0;
|
||||||
|
}
|
||||||
|
|
||||||
var locale = navigator.language;
|
var locale = navigator.language;
|
||||||
if ('locale' in hashParams)
|
if ('locale' in hashParams)
|
||||||
locale = hashParams['locale'];
|
locale = hashParams['locale'];
|
||||||
|
@ -4822,13 +4848,8 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
|
||||||
document.getElementById('viewFind').classList.add('hidden');
|
document.getElementById('viewFind').classList.add('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Listen for warnings to trigger the fallback UI. Errors should be caught
|
// Listen for unsuporrted features to trigger the fallback UI.
|
||||||
// and call PDFView.error() so we don't need to listen for those.
|
PDFJS.UnsupportedManager.listen(PDFView.fallback.bind(PDFView));
|
||||||
PDFJS.LogManager.addLogger({
|
|
||||||
warn: function() {
|
|
||||||
PDFView.fallback();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Suppress context menus for some controls
|
// Suppress context menus for some controls
|
||||||
document.getElementById('scaleSelect').oncontextmenu = noContextMenuHandler;
|
document.getElementById('scaleSelect').oncontextmenu = noContextMenuHandler;
|
||||||
|
@ -5366,9 +5387,10 @@ window.addEventListener('afterprint', function afterPrint(evt) {
|
||||||
window.oRequestAnimationFrame ||
|
window.oRequestAnimationFrame ||
|
||||||
window.msRequestAnimationFrame ||
|
window.msRequestAnimationFrame ||
|
||||||
function startAtOnce(callback) { callback(); };
|
function startAtOnce(callback) { callback(); };
|
||||||
PDFView.animationStartedPromise = new PDFJS.Promise();
|
PDFView.animationStartedPromise = new Promise(function (resolve) {
|
||||||
requestAnimationFrame(function onAnimationFrame() {
|
requestAnimationFrame(function onAnimationFrame() {
|
||||||
PDFView.animationStartedPromise.resolve();
|
resolve();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|