Updated ViewerJS. Fixed build.xml
This commit is contained in:
parent
19e503842b
commit
0fab3c8a3a
@ -186,8 +186,7 @@
|
||||
<copy todir="${target-folder}/${plugin-folder}">
|
||||
<fileset dir=".">
|
||||
<include name="resources/**/*.*"/>
|
||||
<include name="pdfbox/**/*.*"/>
|
||||
<include name="pdfjs/**/*.*"/>
|
||||
<include name="external/**/*.*"/>
|
||||
<include name="php/**/*.php"/>
|
||||
<include name="config.php"/>
|
||||
<!-- exclude the ant script -->
|
||||
|
29
external/ViewerJS/compatibility.js
vendored
29
external/ViewerJS/compatibility.js
vendored
@ -447,20 +447,10 @@ if (typeof PDFJS === 'undefined') {
|
||||
|
||||
// Checks if navigator.language is supported
|
||||
(function checkNavigatorLanguage() {
|
||||
if ('language' in navigator &&
|
||||
/^[a-z]+(-[A-Z]+)?$/.test(navigator.language)) {
|
||||
if ('language' in navigator) {
|
||||
return;
|
||||
}
|
||||
function formatLocale(locale) {
|
||||
var split = locale.split(/[-_]/);
|
||||
split[0] = split[0].toLowerCase();
|
||||
if (split.length > 1) {
|
||||
split[1] = split[1].toUpperCase();
|
||||
}
|
||||
return split.join('-');
|
||||
}
|
||||
var language = navigator.language || navigator.userLanguage || 'en-US';
|
||||
PDFJS.locale = formatLocale(language);
|
||||
PDFJS.locale = navigator.userLanguage || 'en-US';
|
||||
})();
|
||||
|
||||
(function checkRangeRequests() {
|
||||
@ -479,7 +469,10 @@ if (typeof PDFJS === 'undefined') {
|
||||
var regex = /Android\s[0-2][^\d]/;
|
||||
var isOldAndroid = regex.test(navigator.userAgent);
|
||||
|
||||
if (isSafari || isOldAndroid) {
|
||||
// Range requests are broken in Chrome 39 and 40, https://crbug.com/442318
|
||||
var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(navigator.userAgent);
|
||||
|
||||
if (isSafari || isOldAndroid || isChromeWithRangeBug) {
|
||||
PDFJS.disableRange = true;
|
||||
PDFJS.disableStream = true;
|
||||
}
|
||||
@ -572,3 +565,13 @@ if (typeof PDFJS === 'undefined') {
|
||||
PDFJS.maxCanvasPixels = 5242880;
|
||||
}
|
||||
})();
|
||||
|
||||
// Disable fullscreen support for certain problematic configurations.
|
||||
// Support: IE11+ (when embedded).
|
||||
(function checkFullscreenSupport() {
|
||||
var isEmbeddedIE = (navigator.userAgent.indexOf('Trident') >= 0 &&
|
||||
window.parent !== window);
|
||||
if (isEmbeddedIE) {
|
||||
PDFJS.disableFullscreen = true;
|
||||
}
|
||||
})();
|
||||
|
BIN
external/ViewerJS/images/toolbarButton-print.png
vendored
Normal file
BIN
external/ViewerJS/images/toolbarButton-print.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 257 B |
88
external/ViewerJS/index.html
vendored
88
external/ViewerJS/index.html
vendored
File diff suppressed because one or more lines are too long
391
external/ViewerJS/pdf.js
vendored
391
external/ViewerJS/pdf.js
vendored
@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
|
||||
(typeof window !== 'undefined' ? window : this).PDFJS = {};
|
||||
}
|
||||
|
||||
PDFJS.version = '1.0.1040';
|
||||
PDFJS.build = '997096f';
|
||||
PDFJS.version = '1.1.114';
|
||||
PDFJS.build = '3fd44fd';
|
||||
|
||||
(function pdfjsWrapper() {
|
||||
// Use strict in our context only - users might not want it
|
||||
@ -239,17 +239,10 @@ function warn(msg) {
|
||||
// Fatal errors that should trigger the fallback UI and halt execution by
|
||||
// throwing an exception.
|
||||
function error(msg) {
|
||||
// If multiple arguments were passed, pass them all to the log function.
|
||||
if (arguments.length > 1) {
|
||||
var logArguments = ['Error:'];
|
||||
logArguments.push.apply(logArguments, arguments);
|
||||
console.log.apply(console, logArguments);
|
||||
// Join the arguments into a single string for the lines below.
|
||||
msg = [].join.call(arguments, ' ');
|
||||
} else {
|
||||
if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.errors) {
|
||||
console.log('Error: ' + msg);
|
||||
console.log(backtrace());
|
||||
}
|
||||
console.log(backtrace());
|
||||
UnsupportedManager.notify(UNSUPPORTED_FEATURES.unknown);
|
||||
throw new Error(msg);
|
||||
}
|
||||
@ -341,6 +334,7 @@ function isValidUrl(url, allowRelative) {
|
||||
case 'https':
|
||||
case 'ftp':
|
||||
case 'mailto':
|
||||
case 'tel':
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -355,6 +349,7 @@ function shadow(obj, prop, value) {
|
||||
writable: false });
|
||||
return value;
|
||||
}
|
||||
PDFJS.shadow = shadow;
|
||||
|
||||
var PasswordResponses = PDFJS.PasswordResponses = {
|
||||
NEED_PASSWORD: 1,
|
||||
@ -470,6 +465,8 @@ var XRefParseException = (function XRefParseExceptionClosure() {
|
||||
|
||||
|
||||
function bytesToString(bytes) {
|
||||
assert(bytes !== null && typeof bytes === 'object' &&
|
||||
bytes.length !== undefined, 'Invalid argument for bytesToString');
|
||||
var length = bytes.length;
|
||||
var MAX_ARGUMENT_COUNT = 8192;
|
||||
if (length < MAX_ARGUMENT_COUNT) {
|
||||
@ -485,6 +482,7 @@ function bytesToString(bytes) {
|
||||
}
|
||||
|
||||
function stringToBytes(str) {
|
||||
assert(typeof str === 'string', 'Invalid argument for stringToBytes');
|
||||
var length = str.length;
|
||||
var bytes = new Uint8Array(length);
|
||||
for (var i = 0; i < length; ++i) {
|
||||
@ -1002,10 +1000,6 @@ function isString(v) {
|
||||
return typeof v === 'string';
|
||||
}
|
||||
|
||||
function isNull(v) {
|
||||
return v === null;
|
||||
}
|
||||
|
||||
function isName(v) {
|
||||
return v instanceof Name;
|
||||
}
|
||||
@ -1639,7 +1633,7 @@ PDFJS.cMapUrl = (PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl);
|
||||
*/
|
||||
PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
|
||||
|
||||
/*
|
||||
/**
|
||||
* By default fonts are converted to OpenType fonts and loaded via font face
|
||||
* rules. If disabled, the font will be rendered using a built in font renderer
|
||||
* that constructs the glyphs with primitive path commands.
|
||||
@ -1694,6 +1688,9 @@ PDFJS.disableStream = (PDFJS.disableStream === undefined ?
|
||||
* Disable pre-fetching of PDF file data. When range requests are enabled PDF.js
|
||||
* will automatically keep fetching more data even if it isn't needed to display
|
||||
* the current page. This default behavior can be disabled.
|
||||
*
|
||||
* NOTE: It is also necessary to disable streaming, see above,
|
||||
* in order for disabling of pre-fetching to work correctly.
|
||||
* @var {boolean}
|
||||
*/
|
||||
PDFJS.disableAutoFetch = (PDFJS.disableAutoFetch === undefined ?
|
||||
@ -1726,6 +1723,14 @@ PDFJS.disableCreateObjectURL = (PDFJS.disableCreateObjectURL === undefined ?
|
||||
PDFJS.disableWebGL = (PDFJS.disableWebGL === undefined ?
|
||||
true : PDFJS.disableWebGL);
|
||||
|
||||
/**
|
||||
* Disables fullscreen support, and by extension Presentation Mode,
|
||||
* in browsers which support the fullscreen API.
|
||||
* @var {boolean}
|
||||
*/
|
||||
PDFJS.disableFullscreen = (PDFJS.disableFullscreen === undefined ?
|
||||
false : PDFJS.disableFullscreen);
|
||||
|
||||
/**
|
||||
* Enables CSS only zooming.
|
||||
* @var {boolean}
|
||||
@ -1745,19 +1750,30 @@ PDFJS.verbosity = (PDFJS.verbosity === undefined ?
|
||||
PDFJS.VERBOSITY_LEVELS.warnings : PDFJS.verbosity);
|
||||
|
||||
/**
|
||||
* The maximum supported canvas size in total pixels e.g. width * height.
|
||||
* The maximum supported canvas size in total pixels e.g. width * height.
|
||||
* The default value is 4096 * 4096. Use -1 for no limit.
|
||||
* @var {number}
|
||||
*/
|
||||
PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ?
|
||||
16777216 : PDFJS.maxCanvasPixels);
|
||||
|
||||
/**
|
||||
* Opens external links in a new window if enabled. The default behavior opens
|
||||
* external links in the PDF.js window.
|
||||
* @var {boolean}
|
||||
*/
|
||||
PDFJS.openExternalLinksInNewWindow = (
|
||||
PDFJS.openExternalLinksInNewWindow === undefined ?
|
||||
false : PDFJS.openExternalLinksInNewWindow);
|
||||
|
||||
/**
|
||||
* Document initialization / loading parameters object.
|
||||
*
|
||||
* @typedef {Object} DocumentInitParameters
|
||||
* @property {string} url - The URL of the PDF.
|
||||
* @property {TypedArray} data - A typed array with PDF data.
|
||||
* @property {TypedArray|Array|string} data - Binary PDF data. Use typed arrays
|
||||
* (Uint8Array) to improve the memory usage. If PDF data is BASE64-encoded,
|
||||
* use atob() to convert it to a binary string first.
|
||||
* @property {Object} httpHeaders - Basic authentication headers.
|
||||
* @property {boolean} withCredentials - Indicates whether or not cross-site
|
||||
* Access-Control requests should be made using credentials such as cookies
|
||||
@ -1766,6 +1782,9 @@ PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ?
|
||||
* @property {TypedArray} initialData - A typed array with the first portion or
|
||||
* all of the pdf data. Used by the extension since some data is already
|
||||
* loaded before the switch to range requests.
|
||||
* @property {number} length - The PDF file length. It's used for progress
|
||||
* reports and range requests operations.
|
||||
* @property {PDFDataRangeTransport} range
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -1782,68 +1801,226 @@ PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ?
|
||||
* is used, which means it must follow the same origin rules that any XHR does
|
||||
* e.g. No cross domain requests without CORS.
|
||||
*
|
||||
* @param {string|TypedArray|DocumentInitParameters} source Can be a url to
|
||||
* where a PDF is located, a typed array (Uint8Array) already populated with
|
||||
* data or parameter object.
|
||||
* @param {string|TypedArray|DocumentInitParameters|PDFDataRangeTransport} src
|
||||
* Can be a url to where a PDF is located, a typed array (Uint8Array)
|
||||
* already populated with data or parameter object.
|
||||
*
|
||||
* @param {Object} pdfDataRangeTransport is optional. It is used if you want
|
||||
* to manually serve range requests for data in the PDF. See viewer.js for
|
||||
* an example of pdfDataRangeTransport's interface.
|
||||
* @param {PDFDataRangeTransport} pdfDataRangeTransport (deprecated) It is used
|
||||
* if you want to manually serve range requests for data in the PDF.
|
||||
*
|
||||
* @param {function} passwordCallback is optional. It is used to request a
|
||||
* @param {function} passwordCallback (deprecated) It is used to request a
|
||||
* password if wrong or no password was provided. The callback receives two
|
||||
* parameters: function that needs to be called with new password and reason
|
||||
* (see {PasswordResponses}).
|
||||
*
|
||||
* @param {function} progressCallback is optional. It is used to be able to
|
||||
* @param {function} progressCallback (deprecated) It is used to be able to
|
||||
* monitor the loading progress of the PDF file (necessary to implement e.g.
|
||||
* a loading bar). The callback receives an {Object} with the properties:
|
||||
* {number} loaded and {number} total.
|
||||
*
|
||||
* @return {Promise} A promise that is resolved with {@link PDFDocumentProxy}
|
||||
* object.
|
||||
* @return {PDFDocumentLoadingTask}
|
||||
*/
|
||||
PDFJS.getDocument = function getDocument(source,
|
||||
PDFJS.getDocument = function getDocument(src,
|
||||
pdfDataRangeTransport,
|
||||
passwordCallback,
|
||||
progressCallback) {
|
||||
var workerInitializedCapability, workerReadyCapability, transport;
|
||||
var task = new PDFDocumentLoadingTask();
|
||||
|
||||
if (typeof source === 'string') {
|
||||
source = { url: source };
|
||||
} else if (isArrayBuffer(source)) {
|
||||
source = { data: source };
|
||||
} else if (typeof source !== 'object') {
|
||||
error('Invalid parameter in getDocument, need either Uint8Array, ' +
|
||||
'string or a parameter object');
|
||||
// Support of the obsolete arguments (for compatibility with API v1.0)
|
||||
if (pdfDataRangeTransport) {
|
||||
if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
|
||||
// Not a PDFDataRangeTransport instance, trying to add missing properties.
|
||||
pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
|
||||
pdfDataRangeTransport.length = src.length;
|
||||
pdfDataRangeTransport.initialData = src.initialData;
|
||||
}
|
||||
src = Object.create(src);
|
||||
src.range = pdfDataRangeTransport;
|
||||
}
|
||||
task.onPassword = passwordCallback || null;
|
||||
task.onProgress = progressCallback || null;
|
||||
|
||||
var workerInitializedCapability, transport;
|
||||
var source;
|
||||
if (typeof src === 'string') {
|
||||
source = { url: src };
|
||||
} else if (isArrayBuffer(src)) {
|
||||
source = { data: src };
|
||||
} else if (src instanceof PDFDataRangeTransport) {
|
||||
source = { range: src };
|
||||
} else {
|
||||
if (typeof src !== 'object') {
|
||||
error('Invalid parameter in getDocument, need either Uint8Array, ' +
|
||||
'string or a parameter object');
|
||||
}
|
||||
if (!src.url && !src.data && !src.range) {
|
||||
error('Invalid parameter object: need either .data, .range or .url');
|
||||
}
|
||||
|
||||
source = src;
|
||||
}
|
||||
|
||||
if (!source.url && !source.data) {
|
||||
error('Invalid parameter array, need either .data or .url');
|
||||
}
|
||||
|
||||
// copy/use all keys as is except 'url' -- full path is required
|
||||
var params = {};
|
||||
for (var key in source) {
|
||||
if (key === 'url' && typeof window !== 'undefined') {
|
||||
// The full path is required in the 'url' field.
|
||||
params[key] = combineUrl(window.location.href, source[key]);
|
||||
continue;
|
||||
} else if (key === 'range') {
|
||||
continue;
|
||||
} else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
|
||||
// Converting string or array-like data to Uint8Array.
|
||||
var pdfBytes = source[key];
|
||||
if (typeof pdfBytes === 'string') {
|
||||
params[key] = stringToBytes(pdfBytes);
|
||||
} else if (typeof pdfBytes === 'object' && pdfBytes !== null &&
|
||||
!isNaN(pdfBytes.length)) {
|
||||
params[key] = new Uint8Array(pdfBytes);
|
||||
} else {
|
||||
error('Invalid PDF binary data: either typed array, string or ' +
|
||||
'array-like object is expected in the data property.');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
params[key] = source[key];
|
||||
}
|
||||
|
||||
workerInitializedCapability = createPromiseCapability();
|
||||
workerReadyCapability = createPromiseCapability();
|
||||
transport = new WorkerTransport(workerInitializedCapability,
|
||||
workerReadyCapability, pdfDataRangeTransport,
|
||||
progressCallback);
|
||||
transport = new WorkerTransport(workerInitializedCapability, source.range);
|
||||
workerInitializedCapability.promise.then(function transportInitialized() {
|
||||
transport.passwordCallback = passwordCallback;
|
||||
transport.fetchDocument(params);
|
||||
transport.fetchDocument(task, params);
|
||||
});
|
||||
return workerReadyCapability.promise;
|
||||
|
||||
return task;
|
||||
};
|
||||
|
||||
/**
|
||||
* PDF document loading operation.
|
||||
* @class
|
||||
*/
|
||||
var PDFDocumentLoadingTask = (function PDFDocumentLoadingTaskClosure() {
|
||||
/** @constructs PDFDocumentLoadingTask */
|
||||
function PDFDocumentLoadingTask() {
|
||||
this._capability = createPromiseCapability();
|
||||
|
||||
/**
|
||||
* Callback to request a password if wrong or no password was provided.
|
||||
* The callback receives two parameters: function that needs to be called
|
||||
* with new password and reason (see {PasswordResponses}).
|
||||
*/
|
||||
this.onPassword = null;
|
||||
|
||||
/**
|
||||
* Callback to be able to monitor the loading progress of the PDF file
|
||||
* (necessary to implement e.g. a loading bar). The callback receives
|
||||
* an {Object} with the properties: {number} loaded and {number} total.
|
||||
*/
|
||||
this.onProgress = null;
|
||||
}
|
||||
|
||||
PDFDocumentLoadingTask.prototype =
|
||||
/** @lends PDFDocumentLoadingTask.prototype */ {
|
||||
/**
|
||||
* @return {Promise}
|
||||
*/
|
||||
get promise() {
|
||||
return this._capability.promise;
|
||||
},
|
||||
|
||||
// TODO add cancel or abort method
|
||||
|
||||
/**
|
||||
* Registers callbacks to indicate the document loading completion.
|
||||
*
|
||||
* @param {function} onFulfilled The callback for the loading completion.
|
||||
* @param {function} onRejected The callback for the loading failure.
|
||||
* @return {Promise} A promise that is resolved after the onFulfilled or
|
||||
* onRejected callback.
|
||||
*/
|
||||
then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
|
||||
return this.promise.then.apply(this.promise, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
return PDFDocumentLoadingTask;
|
||||
})();
|
||||
|
||||
/**
|
||||
* Abstract class to support range requests file loading.
|
||||
* @class
|
||||
*/
|
||||
var PDFDataRangeTransport = (function pdfDataRangeTransportClosure() {
|
||||
/**
|
||||
* @constructs PDFDataRangeTransport
|
||||
* @param {number} length
|
||||
* @param {Uint8Array} initialData
|
||||
*/
|
||||
function PDFDataRangeTransport(length, initialData) {
|
||||
this.length = length;
|
||||
this.initialData = initialData;
|
||||
|
||||
this._rangeListeners = [];
|
||||
this._progressListeners = [];
|
||||
this._progressiveReadListeners = [];
|
||||
this._readyCapability = createPromiseCapability();
|
||||
}
|
||||
PDFDataRangeTransport.prototype =
|
||||
/** @lends PDFDataRangeTransport.prototype */ {
|
||||
addRangeListener:
|
||||
function PDFDataRangeTransport_addRangeListener(listener) {
|
||||
this._rangeListeners.push(listener);
|
||||
},
|
||||
|
||||
addProgressListener:
|
||||
function PDFDataRangeTransport_addProgressListener(listener) {
|
||||
this._progressListeners.push(listener);
|
||||
},
|
||||
|
||||
addProgressiveReadListener:
|
||||
function PDFDataRangeTransport_addProgressiveReadListener(listener) {
|
||||
this._progressiveReadListeners.push(listener);
|
||||
},
|
||||
|
||||
onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
|
||||
var listeners = this._rangeListeners;
|
||||
for (var i = 0, n = listeners.length; i < n; ++i) {
|
||||
listeners[i](begin, chunk);
|
||||
}
|
||||
},
|
||||
|
||||
onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
|
||||
this._readyCapability.promise.then(function () {
|
||||
var listeners = this._progressListeners;
|
||||
for (var i = 0, n = listeners.length; i < n; ++i) {
|
||||
listeners[i](loaded);
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
onDataProgressiveRead:
|
||||
function PDFDataRangeTransport_onDataProgress(chunk) {
|
||||
this._readyCapability.promise.then(function () {
|
||||
var listeners = this._progressiveReadListeners;
|
||||
for (var i = 0, n = listeners.length; i < n; ++i) {
|
||||
listeners[i](chunk);
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
transportReady: function PDFDataRangeTransport_transportReady() {
|
||||
this._readyCapability.resolve();
|
||||
},
|
||||
|
||||
requestDataRange:
|
||||
function PDFDataRangeTransport_requestDataRange(begin, end) {
|
||||
throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
|
||||
}
|
||||
};
|
||||
return PDFDataRangeTransport;
|
||||
})();
|
||||
|
||||
PDFJS.PDFDataRangeTransport = PDFDataRangeTransport;
|
||||
|
||||
/**
|
||||
* Proxy to a PDFDocument in the worker thread. Also, contains commonly used
|
||||
* properties that can be read synchronously.
|
||||
@ -1959,7 +2136,7 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
|
||||
return this.transport.downloadInfoCapability.promise;
|
||||
},
|
||||
/**
|
||||
* @returns {Promise} A promise this is resolved with current stats about
|
||||
* @return {Promise} A promise this is resolved with current stats about
|
||||
* document structures (see {@link PDFDocumentStats}).
|
||||
*/
|
||||
getStats: function PDFDocumentProxy_getStats() {
|
||||
@ -2023,12 +2200,12 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
|
||||
* (default value is 'display').
|
||||
* @property {Object} imageLayer - (optional) An object that has beginLayout,
|
||||
* endLayout and appendImage functions.
|
||||
* @property {function} continueCallback - (optional) A function that will be
|
||||
* @property {function} continueCallback - (deprecated) A function that will be
|
||||
* called each time the rendering is paused. To continue
|
||||
* rendering call the function that is the first argument
|
||||
* to the callback.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PDF page operator list.
|
||||
*
|
||||
@ -2156,7 +2333,12 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
||||
intentState.renderTasks = [];
|
||||
}
|
||||
intentState.renderTasks.push(internalRenderTask);
|
||||
var renderTask = new RenderTask(internalRenderTask);
|
||||
var renderTask = internalRenderTask.task;
|
||||
|
||||
// Obsolete parameter support
|
||||
if (params.continueCallback) {
|
||||
renderTask.onContinue = params.continueCallback;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
intentState.displayReadyCapability.promise.then(
|
||||
@ -2321,19 +2503,16 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
||||
* @ignore
|
||||
*/
|
||||
var WorkerTransport = (function WorkerTransportClosure() {
|
||||
function WorkerTransport(workerInitializedCapability, workerReadyCapability,
|
||||
pdfDataRangeTransport, progressCallback) {
|
||||
function WorkerTransport(workerInitializedCapability, pdfDataRangeTransport) {
|
||||
this.pdfDataRangeTransport = pdfDataRangeTransport;
|
||||
|
||||
this.workerInitializedCapability = workerInitializedCapability;
|
||||
this.workerReadyCapability = workerReadyCapability;
|
||||
this.progressCallback = progressCallback;
|
||||
this.commonObjs = new PDFObjects();
|
||||
|
||||
this.loadingTask = null;
|
||||
|
||||
this.pageCache = [];
|
||||
this.pagePromises = [];
|
||||
this.downloadInfoCapability = createPromiseCapability();
|
||||
this.passwordCallback = null;
|
||||
|
||||
// If worker support isn't disabled explicit and the browser has worker
|
||||
// support, create a new web worker and test if it/the browser fullfills
|
||||
@ -2482,48 +2661,50 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
||||
this.numPages = data.pdfInfo.numPages;
|
||||
var pdfDocument = new PDFDocumentProxy(pdfInfo, this);
|
||||
this.pdfDocument = pdfDocument;
|
||||
this.workerReadyCapability.resolve(pdfDocument);
|
||||
this.loadingTask._capability.resolve(pdfDocument);
|
||||
}, this);
|
||||
|
||||
messageHandler.on('NeedPassword',
|
||||
function transportNeedPassword(exception) {
|
||||
if (this.passwordCallback) {
|
||||
return this.passwordCallback(updatePassword,
|
||||
PasswordResponses.NEED_PASSWORD);
|
||||
var loadingTask = this.loadingTask;
|
||||
if (loadingTask.onPassword) {
|
||||
return loadingTask.onPassword(updatePassword,
|
||||
PasswordResponses.NEED_PASSWORD);
|
||||
}
|
||||
this.workerReadyCapability.reject(
|
||||
loadingTask._capability.reject(
|
||||
new PasswordException(exception.message, exception.code));
|
||||
}, this);
|
||||
|
||||
messageHandler.on('IncorrectPassword',
|
||||
function transportIncorrectPassword(exception) {
|
||||
if (this.passwordCallback) {
|
||||
return this.passwordCallback(updatePassword,
|
||||
PasswordResponses.INCORRECT_PASSWORD);
|
||||
var loadingTask = this.loadingTask;
|
||||
if (loadingTask.onPassword) {
|
||||
return loadingTask.onPassword(updatePassword,
|
||||
PasswordResponses.INCORRECT_PASSWORD);
|
||||
}
|
||||
this.workerReadyCapability.reject(
|
||||
loadingTask._capability.reject(
|
||||
new PasswordException(exception.message, exception.code));
|
||||
}, this);
|
||||
|
||||
messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
|
||||
this.workerReadyCapability.reject(
|
||||
this.loadingTask._capability.reject(
|
||||
new InvalidPDFException(exception.message));
|
||||
}, this);
|
||||
|
||||
messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
|
||||
this.workerReadyCapability.reject(
|
||||
this.loadingTask._capability.reject(
|
||||
new MissingPDFException(exception.message));
|
||||
}, this);
|
||||
|
||||
messageHandler.on('UnexpectedResponse',
|
||||
function transportUnexpectedResponse(exception) {
|
||||
this.workerReadyCapability.reject(
|
||||
this.loadingTask._capability.reject(
|
||||
new UnexpectedResponseException(exception.message, exception.status));
|
||||
}, this);
|
||||
|
||||
messageHandler.on('UnknownError',
|
||||
function transportUnknownError(exception) {
|
||||
this.workerReadyCapability.reject(
|
||||
this.loadingTask._capability.reject(
|
||||
new UnknownErrorException(exception.message, exception.details));
|
||||
}, this);
|
||||
|
||||
@ -2618,8 +2799,9 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
||||
}, this);
|
||||
|
||||
messageHandler.on('DocProgress', function transportDocProgress(data) {
|
||||
if (this.progressCallback) {
|
||||
this.progressCallback({
|
||||
var loadingTask = this.loadingTask;
|
||||
if (loadingTask.onProgress) {
|
||||
loadingTask.onProgress({
|
||||
loaded: data.loaded,
|
||||
total: data.total
|
||||
});
|
||||
@ -2679,10 +2861,16 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
||||
});
|
||||
},
|
||||
|
||||
fetchDocument: function WorkerTransport_fetchDocument(source) {
|
||||
fetchDocument: function WorkerTransport_fetchDocument(loadingTask, source) {
|
||||
this.loadingTask = loadingTask;
|
||||
|
||||
source.disableAutoFetch = PDFJS.disableAutoFetch;
|
||||
source.disableStream = PDFJS.disableStream;
|
||||
source.chunkedViewerLoading = !!this.pdfDataRangeTransport;
|
||||
if (this.pdfDataRangeTransport) {
|
||||
source.length = this.pdfDataRangeTransport.length;
|
||||
source.initialData = this.pdfDataRangeTransport.initialData;
|
||||
}
|
||||
this.messageHandler.send('GetDocRequest', {
|
||||
source: source,
|
||||
disableRange: PDFJS.disableRange,
|
||||
@ -2893,26 +3081,37 @@ var PDFObjects = (function PDFObjectsClosure() {
|
||||
*/
|
||||
var RenderTask = (function RenderTaskClosure() {
|
||||
function RenderTask(internalRenderTask) {
|
||||
this.internalRenderTask = internalRenderTask;
|
||||
this._internalRenderTask = internalRenderTask;
|
||||
|
||||
/**
|
||||
* Promise for rendering task completion.
|
||||
* @type {Promise}
|
||||
* Callback for incremental rendering -- a function that will be called
|
||||
* each time the rendering is paused. To continue rendering call the
|
||||
* function that is the first argument to the callback.
|
||||
* @type {function}
|
||||
*/
|
||||
this.promise = this.internalRenderTask.capability.promise;
|
||||
this.onContinue = null;
|
||||
}
|
||||
|
||||
RenderTask.prototype = /** @lends RenderTask.prototype */ {
|
||||
/**
|
||||
* Promise for rendering task completion.
|
||||
* @return {Promise}
|
||||
*/
|
||||
get promise() {
|
||||
return this._internalRenderTask.capability.promise;
|
||||
},
|
||||
|
||||
/**
|
||||
* Cancels the rendering task. If the task is currently rendering it will
|
||||
* not be cancelled until graphics pauses with a timeout. The promise that
|
||||
* this object extends will resolved when cancelled.
|
||||
*/
|
||||
cancel: function RenderTask_cancel() {
|
||||
this.internalRenderTask.cancel();
|
||||
this._internalRenderTask.cancel();
|
||||
},
|
||||
|
||||
/**
|
||||
* Registers callback to indicate the rendering task completion.
|
||||
* Registers callbacks to indicate the rendering task completion.
|
||||
*
|
||||
* @param {function} onFulfilled The callback for the rendering completion.
|
||||
* @param {function} onRejected The callback for the rendering failure.
|
||||
@ -2920,7 +3119,7 @@ var RenderTask = (function RenderTaskClosure() {
|
||||
* onRejected callback.
|
||||
*/
|
||||
then: function RenderTask_then(onFulfilled, onRejected) {
|
||||
return this.promise.then(onFulfilled, onRejected);
|
||||
return this.promise.then.apply(this.promise, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
@ -2947,6 +3146,7 @@ var InternalRenderTask = (function InternalRenderTaskClosure() {
|
||||
this.graphicsReady = false;
|
||||
this.cancelled = false;
|
||||
this.capability = createPromiseCapability();
|
||||
this.task = new RenderTask(this);
|
||||
// caching this-bound methods
|
||||
this._continueBound = this._continue.bind(this);
|
||||
this._scheduleNextBound = this._scheduleNext.bind(this);
|
||||
@ -3009,8 +3209,8 @@ var InternalRenderTask = (function InternalRenderTaskClosure() {
|
||||
if (this.cancelled) {
|
||||
return;
|
||||
}
|
||||
if (this.params.continueCallback) {
|
||||
this.params.continueCallback(this._scheduleNextBound);
|
||||
if (this.task.onContinue) {
|
||||
this.task.onContinue.call(this.task, this._scheduleNextBound);
|
||||
} else {
|
||||
this._scheduleNext();
|
||||
}
|
||||
@ -3149,11 +3349,8 @@ function createScratchCanvas(width, height) {
|
||||
}
|
||||
|
||||
function addContextCurrentTransform(ctx) {
|
||||
// If the context doesn't expose a `mozCurrentTransform`, add a JS based on.
|
||||
// If the context doesn't expose a `mozCurrentTransform`, add a JS based one.
|
||||
if (!ctx.mozCurrentTransform) {
|
||||
// Store the original context
|
||||
ctx._scaleX = ctx._scaleX || 1.0;
|
||||
ctx._scaleY = ctx._scaleY || 1.0;
|
||||
ctx._originalSave = ctx.save;
|
||||
ctx._originalRestore = ctx.restore;
|
||||
ctx._originalRotate = ctx.rotate;
|
||||
@ -3162,7 +3359,7 @@ function addContextCurrentTransform(ctx) {
|
||||
ctx._originalTransform = ctx.transform;
|
||||
ctx._originalSetTransform = ctx.setTransform;
|
||||
|
||||
ctx._transformMatrix = [ctx._scaleX, 0, 0, ctx._scaleY, 0, 0];
|
||||
ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0];
|
||||
ctx._transformStack = [];
|
||||
|
||||
Object.defineProperty(ctx, 'mozCurrentTransform', {
|
||||
@ -3538,6 +3735,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
this.smaskCounter = 0;
|
||||
this.tempSMask = null;
|
||||
if (canvasCtx) {
|
||||
// NOTE: if mozCurrentTransform is polyfilled, then the current state of
|
||||
// the transformation must already be set in canvasCtx._transformMatrix.
|
||||
addContextCurrentTransform(canvasCtx);
|
||||
}
|
||||
this.cachedGetSinglePixelWidth = null;
|
||||
@ -5254,7 +5453,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
})();
|
||||
|
||||
|
||||
|
||||
var WebGLUtils = (function WebGLUtilsClosure() {
|
||||
function loadShader(gl, code, shaderType) {
|
||||
var shader = gl.createShader(shaderType);
|
||||
@ -6165,7 +6363,8 @@ var FontLoader = {
|
||||
|
||||
nativeFontFaces: [],
|
||||
|
||||
isFontLoadingAPISupported: !isWorker && !!document.fonts,
|
||||
isFontLoadingAPISupported: (!isWorker && typeof document !== 'undefined' &&
|
||||
!!document.fonts),
|
||||
|
||||
addNativeFontFace: function fontLoader_addNativeFontFace(nativeFontFace) {
|
||||
this.nativeFontFaces.push(nativeFontFace);
|
||||
@ -6634,6 +6833,9 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
|
||||
|
||||
var link = document.createElement('a');
|
||||
link.href = link.title = item.url || '';
|
||||
if (item.url && PDFJS.openExternalLinksInNewWindow) {
|
||||
link.target = '_blank';
|
||||
}
|
||||
|
||||
container.appendChild(link);
|
||||
|
||||
@ -6893,7 +7095,7 @@ var SVGExtraState = (function SVGExtraStateClosure() {
|
||||
this.lineJoin = '';
|
||||
this.lineCap = '';
|
||||
this.miterLimit = 0;
|
||||
|
||||
|
||||
this.dashArray = [];
|
||||
this.dashPhase = 0;
|
||||
|
||||
@ -7120,7 +7322,7 @@ var SVGGraphics = (function SVGGraphicsClosure() {
|
||||
}
|
||||
return opListToTree(opList);
|
||||
},
|
||||
|
||||
|
||||
executeOpTree: function SVGGraphics_executeOpTree(opTree) {
|
||||
var opTreeLen = opTree.length;
|
||||
for(var x = 0; x < opTreeLen; x++) {
|
||||
@ -7159,6 +7361,9 @@ var SVGGraphics = (function SVGGraphicsClosure() {
|
||||
case OPS.setWordSpacing:
|
||||
this.setWordSpacing(args[0]);
|
||||
break;
|
||||
case OPS.setHScale:
|
||||
this.setHScale(args[0]);
|
||||
break;
|
||||
case OPS.setTextMatrix:
|
||||
this.setTextMatrix(args[0], args[1], args[2],
|
||||
args[3], args[4], args[5]);
|
||||
|
447
external/ViewerJS/pdf.worker.js
vendored
447
external/ViewerJS/pdf.worker.js
vendored
@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
|
||||
(typeof window !== 'undefined' ? window : this).PDFJS = {};
|
||||
}
|
||||
|
||||
PDFJS.version = '1.0.1040';
|
||||
PDFJS.build = '997096f';
|
||||
PDFJS.version = '1.1.114';
|
||||
PDFJS.build = '3fd44fd';
|
||||
|
||||
(function pdfjsWrapper() {
|
||||
// Use strict in our context only - users might not want it
|
||||
@ -239,17 +239,10 @@ function warn(msg) {
|
||||
// Fatal errors that should trigger the fallback UI and halt execution by
|
||||
// throwing an exception.
|
||||
function error(msg) {
|
||||
// If multiple arguments were passed, pass them all to the log function.
|
||||
if (arguments.length > 1) {
|
||||
var logArguments = ['Error:'];
|
||||
logArguments.push.apply(logArguments, arguments);
|
||||
console.log.apply(console, logArguments);
|
||||
// Join the arguments into a single string for the lines below.
|
||||
msg = [].join.call(arguments, ' ');
|
||||
} else {
|
||||
if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.errors) {
|
||||
console.log('Error: ' + msg);
|
||||
console.log(backtrace());
|
||||
}
|
||||
console.log(backtrace());
|
||||
UnsupportedManager.notify(UNSUPPORTED_FEATURES.unknown);
|
||||
throw new Error(msg);
|
||||
}
|
||||
@ -341,6 +334,7 @@ function isValidUrl(url, allowRelative) {
|
||||
case 'https':
|
||||
case 'ftp':
|
||||
case 'mailto':
|
||||
case 'tel':
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -355,6 +349,7 @@ function shadow(obj, prop, value) {
|
||||
writable: false });
|
||||
return value;
|
||||
}
|
||||
PDFJS.shadow = shadow;
|
||||
|
||||
var PasswordResponses = PDFJS.PasswordResponses = {
|
||||
NEED_PASSWORD: 1,
|
||||
@ -470,6 +465,8 @@ var XRefParseException = (function XRefParseExceptionClosure() {
|
||||
|
||||
|
||||
function bytesToString(bytes) {
|
||||
assert(bytes !== null && typeof bytes === 'object' &&
|
||||
bytes.length !== undefined, 'Invalid argument for bytesToString');
|
||||
var length = bytes.length;
|
||||
var MAX_ARGUMENT_COUNT = 8192;
|
||||
if (length < MAX_ARGUMENT_COUNT) {
|
||||
@ -485,6 +482,7 @@ function bytesToString(bytes) {
|
||||
}
|
||||
|
||||
function stringToBytes(str) {
|
||||
assert(typeof str === 'string', 'Invalid argument for stringToBytes');
|
||||
var length = str.length;
|
||||
var bytes = new Uint8Array(length);
|
||||
for (var i = 0; i < length; ++i) {
|
||||
@ -1002,10 +1000,6 @@ function isString(v) {
|
||||
return typeof v === 'string';
|
||||
}
|
||||
|
||||
function isNull(v) {
|
||||
return v === null;
|
||||
}
|
||||
|
||||
function isName(v) {
|
||||
return v instanceof Name;
|
||||
}
|
||||
@ -1874,7 +1868,6 @@ var NetworkManager = (function NetworkManagerClosure() {
|
||||
})();
|
||||
|
||||
|
||||
|
||||
var ChunkedStream = (function ChunkedStreamClosure() {
|
||||
function ChunkedStream(length, chunkSize, manager) {
|
||||
this.bytes = new Uint8Array(length);
|
||||
@ -2026,6 +2019,9 @@ var ChunkedStream = (function ChunkedStreamClosure() {
|
||||
getUint16: function ChunkedStream_getUint16() {
|
||||
var b0 = this.getByte();
|
||||
var b1 = this.getByte();
|
||||
if (b0 === -1 || b1 === -1) {
|
||||
return -1;
|
||||
}
|
||||
return (b0 << 8) + b1;
|
||||
},
|
||||
|
||||
@ -2415,7 +2411,6 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
|
||||
})();
|
||||
|
||||
|
||||
|
||||
// The maximum number of bytes fetched per range request
|
||||
var RANGE_CHUNK_SIZE = 65536;
|
||||
|
||||
@ -2621,7 +2616,6 @@ var NetworkPdfManager = (function NetworkPdfManagerClosure() {
|
||||
})();
|
||||
|
||||
|
||||
|
||||
var Page = (function PageClosure() {
|
||||
|
||||
var LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
|
||||
@ -3131,7 +3125,6 @@ var PDFDocument = (function PDFDocumentClosure() {
|
||||
})();
|
||||
|
||||
|
||||
|
||||
var Name = (function NameClosure() {
|
||||
function Name(name) {
|
||||
this.name = name;
|
||||
@ -3301,6 +3294,10 @@ var Dict = (function DictClosure() {
|
||||
return all;
|
||||
},
|
||||
|
||||
getKeys: function Dict_getKeys() {
|
||||
return Object.keys(this.map);
|
||||
},
|
||||
|
||||
set: function Dict_set(key, value) {
|
||||
this.map[key] = value;
|
||||
},
|
||||
@ -3664,7 +3661,7 @@ var Catalog = (function CatalogClosure() {
|
||||
var isPrintAction = (isName(objType) && objType.name === 'Action' &&
|
||||
isName(actionType) && actionType.name === 'Named' &&
|
||||
isName(action) && action.name === 'Print');
|
||||
|
||||
|
||||
if (isPrintAction) {
|
||||
javaScript.push('print(true);');
|
||||
}
|
||||
@ -3706,6 +3703,7 @@ var Catalog = (function CatalogClosure() {
|
||||
var nodesToVisit = [this.catDict.getRaw('Pages')];
|
||||
var currentPageIndex = 0;
|
||||
var xref = this.xref;
|
||||
var checkAllKids = false;
|
||||
|
||||
function next() {
|
||||
while (nodesToVisit.length) {
|
||||
@ -3713,7 +3711,7 @@ var Catalog = (function CatalogClosure() {
|
||||
|
||||
if (isRef(currentNode)) {
|
||||
xref.fetchAsync(currentNode).then(function (obj) {
|
||||
if ((isDict(obj, 'Page') || (isDict(obj) && !obj.has('Kids')))) {
|
||||
if (isDict(obj, 'Page') || (isDict(obj) && !obj.has('Kids'))) {
|
||||
if (pageIndex === currentPageIndex) {
|
||||
capability.resolve([obj, currentNode]);
|
||||
} else {
|
||||
@ -3728,12 +3726,17 @@ var Catalog = (function CatalogClosure() {
|
||||
return;
|
||||
}
|
||||
|
||||
// must be a child page dictionary
|
||||
// Must be a child page dictionary.
|
||||
assert(
|
||||
isDict(currentNode),
|
||||
'page dictionary kid reference points to wrong type of object'
|
||||
);
|
||||
var count = currentNode.get('Count');
|
||||
// If the current node doesn't have any children, avoid getting stuck
|
||||
// in an empty node further down in the tree (see issue5644.pdf).
|
||||
if (count === 0) {
|
||||
checkAllKids = true;
|
||||
}
|
||||
// Skip nodes where the page can't be.
|
||||
if (currentPageIndex + count <= pageIndex) {
|
||||
currentPageIndex += count;
|
||||
@ -3742,7 +3745,7 @@ var Catalog = (function CatalogClosure() {
|
||||
|
||||
var kids = currentNode.get('Kids');
|
||||
assert(isArray(kids), 'page dictionary kids object is not an array');
|
||||
if (count === kids.length) {
|
||||
if (!checkAllKids && count === kids.length) {
|
||||
// Nodes that don't have the page have been skipped and this is the
|
||||
// bottom of the tree which means the page requested must be a
|
||||
// descendant of this pages node. Ideally we would just resolve the
|
||||
@ -4520,7 +4523,7 @@ var NameTree = (function NameTreeClosure() {
|
||||
warn('Search depth limit for named destionations has been reached.');
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
var kids = kidsOrNames.get('Kids');
|
||||
if (!isArray(kids)) {
|
||||
return null;
|
||||
@ -4575,10 +4578,10 @@ var NameTree = (function NameTreeClosure() {
|
||||
})();
|
||||
|
||||
/**
|
||||
* "A PDF file can refer to the contents of another file by using a File
|
||||
* "A PDF file can refer to the contents of another file by using a File
|
||||
* Specification (PDF 1.1)", see the spec (7.11) for more details.
|
||||
* NOTE: Only embedded files are supported (as part of the attachments support)
|
||||
* TODO: support the 'URL' file system (with caching if !/V), portable
|
||||
* TODO: support the 'URL' file system (with caching if !/V), portable
|
||||
* collections attributes and related files (/RF)
|
||||
*/
|
||||
var FileSpec = (function FileSpecClosure() {
|
||||
@ -4908,7 +4911,6 @@ var ExpertSubsetCharset = [
|
||||
];
|
||||
|
||||
|
||||
|
||||
var DEFAULT_ICON_SIZE = 22; // px
|
||||
var SUPPORTED_TYPES = ['Link', 'Text', 'Widget'];
|
||||
|
||||
@ -5374,7 +5376,7 @@ var LinkAnnotation = (function LinkAnnotationClosure() {
|
||||
data.annotationType = AnnotationType.LINK;
|
||||
|
||||
var action = dict.get('A');
|
||||
if (action) {
|
||||
if (action && isDict(action)) {
|
||||
var linkType = action.get('S').name;
|
||||
if (linkType === 'URI') {
|
||||
var url = action.get('URI');
|
||||
@ -6802,10 +6804,10 @@ var ColorSpace = (function ColorSpaceClosure() {
|
||||
case 'CMYK':
|
||||
return 'DeviceCmykCS';
|
||||
case 'CalGray':
|
||||
params = cs[1].getAll();
|
||||
params = xref.fetchIfRef(cs[1]).getAll();
|
||||
return ['CalGrayCS', params];
|
||||
case 'CalRGB':
|
||||
params = cs[1].getAll();
|
||||
params = xref.fetchIfRef(cs[1]).getAll();
|
||||
return ['CalRGBCS', params];
|
||||
case 'ICCBased':
|
||||
var stream = xref.fetchIfRef(cs[1]);
|
||||
@ -9721,7 +9723,7 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {
|
||||
this.cf = dict.get('CF');
|
||||
this.stmf = dict.get('StmF') || identityName;
|
||||
this.strf = dict.get('StrF') || identityName;
|
||||
this.eff = dict.get('EFF') || this.strf;
|
||||
this.eff = dict.get('EFF') || this.stmf;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9796,6 +9798,7 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {
|
||||
return CipherTransformFactory;
|
||||
})();
|
||||
|
||||
|
||||
var PatternType = {
|
||||
FUNCTION_BASED: 1,
|
||||
AXIAL: 2,
|
||||
@ -11446,7 +11449,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
styles: Object.create(null)
|
||||
};
|
||||
var bidiTexts = textContent.items;
|
||||
var SPACE_FACTOR = 0.35;
|
||||
var SPACE_FACTOR = 0.3;
|
||||
var MULTI_SPACE_FACTOR = 1.5;
|
||||
|
||||
var self = this;
|
||||
@ -11885,11 +11888,18 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
var cmap, cmapObj = toUnicode;
|
||||
if (isName(cmapObj)) {
|
||||
cmap = CMapFactory.create(cmapObj,
|
||||
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).getMap();
|
||||
return new ToUnicodeMap(cmap);
|
||||
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null);
|
||||
if (cmap instanceof IdentityCMap) {
|
||||
return new IdentityToUnicodeMap(0, 0xFFFF);
|
||||
}
|
||||
return new ToUnicodeMap(cmap.getMap());
|
||||
} else if (isStream(cmapObj)) {
|
||||
cmap = CMapFactory.create(cmapObj,
|
||||
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).getMap();
|
||||
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null);
|
||||
if (cmap instanceof IdentityCMap) {
|
||||
return new IdentityToUnicodeMap(0, 0xFFFF);
|
||||
}
|
||||
cmap = cmap.getMap();
|
||||
// Convert UTF-16BE
|
||||
// NOTE: cmap can be a sparse array, so use forEach instead of for(;;)
|
||||
// to iterate over all keys.
|
||||
@ -12117,6 +12127,21 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
hash.update(encoding.name);
|
||||
} else if (isRef(encoding)) {
|
||||
hash.update(encoding.num + '_' + encoding.gen);
|
||||
} else if (isDict(encoding)) {
|
||||
var keys = encoding.getKeys();
|
||||
for (var i = 0, ii = keys.length; i < ii; i++) {
|
||||
var entry = encoding.getRaw(keys[i]);
|
||||
if (isName(entry)) {
|
||||
hash.update(entry.name);
|
||||
} else if (isRef(entry)) {
|
||||
hash.update(entry.num + '_' + entry.gen);
|
||||
} else if (isArray(entry)) { // 'Differences' entry.
|
||||
// Ideally we should check the contents of the array, but to avoid
|
||||
// parsing it here and then again in |extractDataStructures|,
|
||||
// we only use the array length for now (fixes bug1157493.pdf).
|
||||
hash.update(entry.length.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
|
||||
@ -13384,6 +13409,7 @@ var CMap = (function CMapClosure() {
|
||||
// - bf chars are variable-length byte sequences, stored as strings, with
|
||||
// one byte per character.
|
||||
this._map = [];
|
||||
this.name = '';
|
||||
this.vertical = false;
|
||||
this.useCMap = null;
|
||||
this.builtInCMap = builtInCMap;
|
||||
@ -13483,13 +13509,28 @@ var CMap = (function CMapClosure() {
|
||||
}
|
||||
out.charcode = 0;
|
||||
out.length = 1;
|
||||
},
|
||||
|
||||
get isIdentityCMap() {
|
||||
if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
|
||||
return false;
|
||||
}
|
||||
if (this._map.length !== 0x10000) {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < 0x10000; i++) {
|
||||
if (this._map[i] !== i) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
return CMap;
|
||||
})();
|
||||
|
||||
// A special case of CMap, where the _map array implicitly has a length of
|
||||
// 65535 and each element is equal to its index.
|
||||
// 65536 and each element is equal to its index.
|
||||
var IdentityCMap = (function IdentityCMapClosure() {
|
||||
function IdentityCMap(vertical, n) {
|
||||
CMap.call(this);
|
||||
@ -13544,7 +13585,11 @@ var IdentityCMap = (function IdentityCMapClosure() {
|
||||
return map;
|
||||
},
|
||||
|
||||
readCharCode: CMap.prototype.readCharCode
|
||||
readCharCode: CMap.prototype.readCharCode,
|
||||
|
||||
get isIdentityCMap() {
|
||||
error('should not access .isIdentityCMap');
|
||||
}
|
||||
};
|
||||
|
||||
return IdentityCMap;
|
||||
@ -14009,6 +14054,13 @@ var CMapFactory = (function CMapFactoryClosure() {
|
||||
}
|
||||
}
|
||||
|
||||
function parseCMapName(cMap, lexer) {
|
||||
var obj = lexer.getObj();
|
||||
if (isName(obj) && isString(obj.name)) {
|
||||
cMap.name = obj.name;
|
||||
}
|
||||
}
|
||||
|
||||
function parseCMap(cMap, lexer, builtInCMapParams, useCMap) {
|
||||
var previous;
|
||||
var embededUseCMap;
|
||||
@ -14019,6 +14071,8 @@ var CMapFactory = (function CMapFactoryClosure() {
|
||||
} else if (isName(obj)) {
|
||||
if (obj.name === 'WMode') {
|
||||
parseWMode(cMap, lexer);
|
||||
} else if (obj.name === 'CMapName') {
|
||||
parseCMapName(cMap, lexer);
|
||||
}
|
||||
previous = obj;
|
||||
} else if (isCmd(obj)) {
|
||||
@ -14128,6 +14182,9 @@ var CMapFactory = (function CMapFactoryClosure() {
|
||||
} catch (e) {
|
||||
warn('Invalid CMap data. ' + e);
|
||||
}
|
||||
if (cMap.isIdentityCMap) {
|
||||
return createBuiltInCMap(cMap.name, builtInCMapParams);
|
||||
}
|
||||
return cMap;
|
||||
}
|
||||
error('Encoding required.');
|
||||
@ -14637,7 +14694,7 @@ var SpecialPUASymbols = {
|
||||
'63731': 0x23A9, // braceleftbt (0xF8F3)
|
||||
'63740': 0x23AB, // bracerighttp (0xF8FC)
|
||||
'63741': 0x23AC, // bracerightmid (0xF8FD)
|
||||
'63742': 0x23AD, // bracerightmid (0xF8FE)
|
||||
'63742': 0x23AD, // bracerightbt (0xF8FE)
|
||||
'63726': 0x23A1, // bracketlefttp (0xF8EE)
|
||||
'63727': 0x23A2, // bracketleftex (0xF8EF)
|
||||
'63728': 0x23A3, // bracketleftbt (0xF8F0)
|
||||
@ -16317,6 +16374,10 @@ var ToUnicodeMap = (function ToUnicodeMapClosure() {
|
||||
}
|
||||
},
|
||||
|
||||
has: function(i) {
|
||||
return this._map[i] !== undefined;
|
||||
},
|
||||
|
||||
get: function(i) {
|
||||
return this._map[i];
|
||||
},
|
||||
@ -16337,7 +16398,7 @@ var IdentityToUnicodeMap = (function IdentityToUnicodeMapClosure() {
|
||||
|
||||
IdentityToUnicodeMap.prototype = {
|
||||
get length() {
|
||||
error('should not access .length');
|
||||
return (this.lastChar + 1) - this.firstChar;
|
||||
},
|
||||
|
||||
forEach: function (callback) {
|
||||
@ -16346,6 +16407,10 @@ var IdentityToUnicodeMap = (function IdentityToUnicodeMapClosure() {
|
||||
}
|
||||
},
|
||||
|
||||
has: function (i) {
|
||||
return this.firstChar <= i && i <= this.lastChar;
|
||||
},
|
||||
|
||||
get: function (i) {
|
||||
if (this.firstChar <= i && i <= this.lastChar) {
|
||||
return String.fromCharCode(i);
|
||||
@ -16577,7 +16642,7 @@ var Font = (function FontClosure() {
|
||||
// to be used with the canvas.font.
|
||||
var fontName = name.replace(/[,_]/g, '-');
|
||||
var isStandardFont = !!stdFontMap[fontName] ||
|
||||
(nonStdFontMap[fontName] && !!stdFontMap[nonStdFontMap[fontName]]);
|
||||
!!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
|
||||
fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
|
||||
|
||||
this.bold = (fontName.search(/bold/gi) !== -1);
|
||||
@ -16678,11 +16743,13 @@ var Font = (function FontClosure() {
|
||||
if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
|
||||
|