mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge remote-tracking branch 'mozilla/version-2.0' into v2
This commit is contained in:
commit
b4e25fb2e8
18 changed files with 66 additions and 252 deletions
|
@ -371,7 +371,7 @@ var Catalog = (function CatalogClosure() {
|
|||
var xref = this.xref;
|
||||
var obj = this.catDict.get('Names');
|
||||
|
||||
var javaScript = [];
|
||||
let javaScript = null;
|
||||
function appendIfJavaScriptDict(jsDict) {
|
||||
var type = jsDict.get('S');
|
||||
if (!isName(type, 'JavaScript')) {
|
||||
|
@ -383,6 +383,9 @@ var Catalog = (function CatalogClosure() {
|
|||
} else if (!isString(js)) {
|
||||
return;
|
||||
}
|
||||
if (!javaScript) {
|
||||
javaScript = [];
|
||||
}
|
||||
javaScript.push(stringToPDFString(js));
|
||||
}
|
||||
if (obj && obj.has('JavaScript')) {
|
||||
|
@ -407,6 +410,9 @@ var Catalog = (function CatalogClosure() {
|
|||
// but is supported by many PDF readers/writers (including Adobe's).
|
||||
var action = openactionDict.get('N');
|
||||
if (isName(action, 'Print')) {
|
||||
if (!javaScript) {
|
||||
javaScript = [];
|
||||
}
|
||||
javaScript.push('print({});');
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
/* globals requirejs, __non_webpack_require__ */
|
||||
|
||||
import {
|
||||
assert, createPromiseCapability, deprecated, getVerbosityLevel, info,
|
||||
assert, createPromiseCapability, getVerbosityLevel, info,
|
||||
InvalidPDFException, isArrayBuffer, isSameOrigin, loadJpegStream,
|
||||
MessageHandler, MissingPDFException, NativeImageDecoding, PageViewport,
|
||||
PasswordException, StatTimer, stringToBytes, UnexpectedResponseException,
|
||||
|
@ -120,10 +120,6 @@ function setPDFNetworkStreamClass(cls) {
|
|||
* @property {string} docBaseUrl - (optional) The base URL of the document,
|
||||
* used when attempting to recover valid absolute URLs for annotations, and
|
||||
* outline items, that (incorrectly) only specify relative URLs.
|
||||
* @property {boolean} disableNativeImageDecoder - (deprecated) Disable decoding
|
||||
* of certain (simple) JPEG images in the browser. This is useful for
|
||||
* environments without DOM image support, such as e.g. Node.js.
|
||||
* The default value is `false`.
|
||||
* @property {string} nativeImageDecoderSupport - (optional) Strategy for
|
||||
* decoding certain (simple) JPEG images in the browser. This is useful for
|
||||
* environments without DOM image and canvas support, such as e.g. Node.js.
|
||||
|
@ -160,46 +156,11 @@ function setPDFNetworkStreamClass(cls) {
|
|||
* Can be a url to where a PDF is located, a typed array (Uint8Array)
|
||||
* already populated with data or parameter object.
|
||||
*
|
||||
* @param {PDFDataRangeTransport} pdfDataRangeTransport (deprecated) It is used
|
||||
* if you want to manually serve range requests for data in the PDF.
|
||||
*
|
||||
* @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 (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 {PDFDocumentLoadingTask}
|
||||
*/
|
||||
function getDocument(src, pdfDataRangeTransport,
|
||||
passwordCallback, progressCallback) {
|
||||
function getDocument(src) {
|
||||
var task = new PDFDocumentLoadingTask();
|
||||
|
||||
// Support of the obsolete arguments (for compatibility with API v1.0)
|
||||
if (arguments.length > 1) {
|
||||
deprecated('getDocument is called with pdfDataRangeTransport, ' +
|
||||
'passwordCallback or progressCallback argument');
|
||||
}
|
||||
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;
|
||||
if (!pdfDataRangeTransport.abort) {
|
||||
pdfDataRangeTransport.abort = function () {};
|
||||
}
|
||||
}
|
||||
src = Object.create(src);
|
||||
src.range = pdfDataRangeTransport;
|
||||
}
|
||||
task.onPassword = passwordCallback || null;
|
||||
task.onProgress = progressCallback || null;
|
||||
|
||||
var source;
|
||||
if (typeof src === 'string') {
|
||||
source = { url: src, };
|
||||
|
@ -262,18 +223,9 @@ function getDocument(src, pdfDataRangeTransport,
|
|||
params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
|
||||
params.ignoreErrors = params.stopAtErrors !== true;
|
||||
|
||||
if (params.disableNativeImageDecoder !== undefined) {
|
||||
deprecated('parameter disableNativeImageDecoder, ' +
|
||||
'use nativeImageDecoderSupport instead');
|
||||
}
|
||||
params.nativeImageDecoderSupport = params.nativeImageDecoderSupport ||
|
||||
(params.disableNativeImageDecoder === true ? NativeImageDecoding.NONE :
|
||||
NativeImageDecoding.DECODE);
|
||||
if (params.nativeImageDecoderSupport !== NativeImageDecoding.DECODE &&
|
||||
params.nativeImageDecoderSupport !== NativeImageDecoding.NONE &&
|
||||
params.nativeImageDecoderSupport !== NativeImageDecoding.DISPLAY) {
|
||||
warn('Invalid parameter nativeImageDecoderSupport: ' +
|
||||
'need a state of enum {NativeImageDecoding}');
|
||||
const nativeImageDecoderValues = Object.values(NativeImageDecoding);
|
||||
if (params.nativeImageDecoderSupport === undefined ||
|
||||
!nativeImageDecoderValues.includes(params.nativeImageDecoderSupport)) {
|
||||
params.nativeImageDecoderSupport = NativeImageDecoding.DECODE;
|
||||
}
|
||||
|
||||
|
@ -618,10 +570,10 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
|
|||
return this.transport.getAttachments();
|
||||
},
|
||||
/**
|
||||
* @return {Promise} A promise that is resolved with an array of all the
|
||||
* JavaScript strings in the name tree.
|
||||
* @return {Promise} A promise that is resolved with an {Array} of all the
|
||||
* JavaScript strings in the name tree, or `null` if no JavaScript exists.
|
||||
*/
|
||||
getJavaScript: function PDFDocumentProxy_getJavaScript() {
|
||||
getJavaScript() {
|
||||
return this.transport.getJavaScript();
|
||||
},
|
||||
/**
|
||||
|
@ -756,10 +708,6 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
|
|||
* just before viewport transform.
|
||||
* @property {Object} imageLayer - (optional) An object that has beginLayout,
|
||||
* endLayout and appendImage functions.
|
||||
* @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.
|
||||
* @property {Object} canvasFactory - (optional) The factory that will be used
|
||||
* when creating canvases. The default value is
|
||||
* {DOMCanvasFactory}.
|
||||
|
@ -933,12 +881,6 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
|||
intentState.renderTasks.push(internalRenderTask);
|
||||
var renderTask = internalRenderTask.task;
|
||||
|
||||
// Obsolete parameter support
|
||||
if (params.continueCallback) {
|
||||
deprecated('render is used with continueCallback parameter');
|
||||
renderTask.onContinue = params.continueCallback;
|
||||
}
|
||||
|
||||
intentState.displayReadyCapability.promise.then((transparency) => {
|
||||
if (this.pendingCleanup) {
|
||||
complete();
|
||||
|
@ -1073,14 +1015,6 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
|||
return Promise.all(waitOn);
|
||||
},
|
||||
|
||||
/**
|
||||
* Cleans up resources allocated by the page. (deprecated)
|
||||
*/
|
||||
destroy() {
|
||||
deprecated('page destroy method, use cleanup() instead');
|
||||
this.cleanup();
|
||||
},
|
||||
|
||||
/**
|
||||
* Cleans up resources allocated by the page.
|
||||
*/
|
||||
|
@ -1908,17 +1842,14 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||
}
|
||||
}, this);
|
||||
|
||||
messageHandler.on('UnsupportedFeature',
|
||||
function transportUnsupportedFeature(data) {
|
||||
messageHandler.on('UnsupportedFeature', function(data) {
|
||||
if (this.destroyed) {
|
||||
return; // Ignore any pending requests if the worker was terminated.
|
||||
}
|
||||
var featureId = data.featureId;
|
||||
var loadingTask = this.loadingTask;
|
||||
let loadingTask = this.loadingTask;
|
||||
if (loadingTask.onUnsupportedFeature) {
|
||||
loadingTask.onUnsupportedFeature(featureId);
|
||||
loadingTask.onUnsupportedFeature(data.featureId);
|
||||
}
|
||||
_UnsupportedManager.notify(featureId);
|
||||
}, this);
|
||||
|
||||
messageHandler.on('JpegDecode', function(data) {
|
||||
|
@ -2325,14 +2256,8 @@ var InternalRenderTask = (function InternalRenderTaskClosure() {
|
|||
if (this._canvas) {
|
||||
canvasInRendering.delete(this._canvas);
|
||||
}
|
||||
|
||||
if ((typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PDFJS_NEXT')) ||
|
||||
getDefaultSetting('pdfjsNext')) {
|
||||
this.callback(new RenderingCancelledException(
|
||||
'Rendering cancelled, page ' + this.pageNumber, 'canvas'));
|
||||
} else {
|
||||
this.callback('cancelled');
|
||||
}
|
||||
this.callback(new RenderingCancelledException(
|
||||
'Rendering cancelled, page ' + this.pageNumber, 'canvas'));
|
||||
},
|
||||
|
||||
operatorListChanged: function InternalRenderTask_operatorListChanged() {
|
||||
|
@ -2398,26 +2323,6 @@ var InternalRenderTask = (function InternalRenderTaskClosure() {
|
|||
return InternalRenderTask;
|
||||
})();
|
||||
|
||||
/**
|
||||
* (Deprecated) Global observer of unsupported feature usages. Use
|
||||
* onUnsupportedFeature callback of the {PDFDocumentLoadingTask} instance.
|
||||
*/
|
||||
var _UnsupportedManager = (function UnsupportedManagerClosure() {
|
||||
var listeners = [];
|
||||
return {
|
||||
listen(cb) {
|
||||
deprecated('Global UnsupportedManager.listen is used: ' +
|
||||
' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
|
||||
listeners.push(cb);
|
||||
},
|
||||
notify(featureId) {
|
||||
for (var i = 0, ii = listeners.length; i < ii; i++) {
|
||||
listeners[i](featureId);
|
||||
}
|
||||
},
|
||||
};
|
||||
})();
|
||||
|
||||
var version, build;
|
||||
if (typeof PDFJSDev !== 'undefined') {
|
||||
version = PDFJSDev.eval('BUNDLE_VERSION');
|
||||
|
@ -2432,7 +2337,6 @@ export {
|
|||
PDFDocumentProxy,
|
||||
PDFPageProxy,
|
||||
setPDFNetworkStreamClass,
|
||||
_UnsupportedManager,
|
||||
version,
|
||||
build,
|
||||
};
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
assert, CMapCompressionType, createValidAbsoluteUrl, deprecated,
|
||||
removeNullCharacters, stringToBytes, warn
|
||||
assert, CMapCompressionType, removeNullCharacters, stringToBytes, warn
|
||||
} from '../shared/util';
|
||||
import globalScope from '../shared/global_scope';
|
||||
|
||||
|
@ -444,8 +443,6 @@ function getDefaultSetting(id) {
|
|||
return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
|
||||
case 'enableStats':
|
||||
return !!(globalSettings && globalSettings.enableStats);
|
||||
case 'pdfjsNext':
|
||||
return !!(globalSettings && globalSettings.pdfjsNext);
|
||||
default:
|
||||
throw new Error('Unknown default setting: ' + id);
|
||||
}
|
||||
|
@ -464,18 +461,11 @@ function isExternalLinkTargetSet() {
|
|||
}
|
||||
}
|
||||
|
||||
function isValidUrl(url, allowRelative) {
|
||||
deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
|
||||
var baseUrl = allowRelative ? 'http://example.com' : null;
|
||||
return createValidAbsoluteUrl(url, baseUrl) !== null;
|
||||
}
|
||||
|
||||
export {
|
||||
CustomStyle,
|
||||
RenderingCancelledException,
|
||||
addLinkAttributes,
|
||||
isExternalLinkTargetSet,
|
||||
isValidUrl,
|
||||
getFilenameFromUrl,
|
||||
LinkTarget,
|
||||
getDefaultSetting,
|
||||
|
|
|
@ -13,21 +13,20 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
_UnsupportedManager, getDocument, LoopbackPort, PDFDataRangeTransport,
|
||||
PDFWorker
|
||||
} from './api';
|
||||
import {
|
||||
addLinkAttributes, CustomStyle, DEFAULT_LINK_REL, getFilenameFromUrl,
|
||||
isExternalLinkTargetSet, isValidUrl, LinkTarget
|
||||
} from './dom_utils';
|
||||
import {
|
||||
createBlob, createObjectURL, createPromiseCapability, deprecated,
|
||||
getVerbosityLevel, InvalidPDFException, isLittleEndian,
|
||||
MissingPDFException, OPS, PageViewport, PasswordException, PasswordResponses,
|
||||
removeNullCharacters, setVerbosityLevel, shadow, UnexpectedResponseException,
|
||||
UnknownErrorException, UNSUPPORTED_FEATURES, Util, VERBOSITY_LEVELS, warn
|
||||
createBlob, createObjectURL, createPromiseCapability, getVerbosityLevel,
|
||||
InvalidPDFException, isLittleEndian, MissingPDFException, OPS, PageViewport,
|
||||
PasswordException, PasswordResponses, removeNullCharacters, setVerbosityLevel,
|
||||
shadow, UnexpectedResponseException, UnknownErrorException,
|
||||
UNSUPPORTED_FEATURES, Util, VERBOSITY_LEVELS
|
||||
} from '../shared/util';
|
||||
import {
|
||||
getDocument, LoopbackPort, PDFDataRangeTransport, PDFWorker
|
||||
} from './api';
|
||||
import { AnnotationLayer } from './annotation_layer';
|
||||
import globalScope from '../shared/global_scope';
|
||||
import { Metadata } from './metadata';
|
||||
|
@ -239,47 +238,6 @@ PDFJS.externalLinkRel = (PDFJS.externalLinkRel === undefined ?
|
|||
PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ?
|
||||
true : PDFJS.isEvalSupported);
|
||||
|
||||
/**
|
||||
* Opt-in to backwards incompatible API changes. NOTE:
|
||||
* If the `PDFJS_NEXT` build flag is set, it will override this setting.
|
||||
* @var {boolean}
|
||||
*/
|
||||
PDFJS.pdfjsNext = (PDFJS.pdfjsNext === undefined) ? false : PDFJS.pdfjsNext;
|
||||
|
||||
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('MOZCENTRAL')) {
|
||||
var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
|
||||
delete PDFJS.openExternalLinksInNewWindow;
|
||||
Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
|
||||
get() {
|
||||
return PDFJS.externalLinkTarget === LinkTarget.BLANK;
|
||||
},
|
||||
set(value) {
|
||||
if (value) {
|
||||
deprecated('PDFJS.openExternalLinksInNewWindow, please use ' +
|
||||
'"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
|
||||
}
|
||||
if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
|
||||
warn('PDFJS.externalLinkTarget is already initialized');
|
||||
return;
|
||||
}
|
||||
PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
});
|
||||
if (savedOpenExternalLinksInNewWindow) {
|
||||
/**
|
||||
* (Deprecated) Opens external links in a new window if enabled.
|
||||
* The default behavior opens external links in the PDF.js window.
|
||||
*
|
||||
* NOTE: This property has been deprecated, please use
|
||||
* `PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK` instead.
|
||||
* @var {boolean}
|
||||
*/
|
||||
PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
|
||||
}
|
||||
}
|
||||
|
||||
PDFJS.getDocument = getDocument;
|
||||
PDFJS.LoopbackPort = LoopbackPort;
|
||||
PDFJS.PDFDataRangeTransport = PDFDataRangeTransport;
|
||||
|
@ -300,8 +258,6 @@ PDFJS.Metadata = Metadata;
|
|||
|
||||
PDFJS.SVGGraphics = SVGGraphics;
|
||||
|
||||
PDFJS.UnsupportedManager = _UnsupportedManager;
|
||||
|
||||
export {
|
||||
globalScope,
|
||||
PDFJS,
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { assert, deprecated } from '../shared/util';
|
||||
import { assert } from '../shared/util';
|
||||
import { SimpleXMLParser } from './dom_utils';
|
||||
|
||||
class Metadata {
|
||||
|
@ -98,11 +98,6 @@ class Metadata {
|
|||
has(name) {
|
||||
return typeof this._metadata[name] !== 'undefined';
|
||||
}
|
||||
|
||||
get metadata() {
|
||||
deprecated('`metadata` getter; use `getAll()` instead.');
|
||||
return this.getAll();
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
|
|
|
@ -64,7 +64,6 @@ exports.UnexpectedResponseException =
|
|||
pdfjsSharedUtil.UnexpectedResponseException;
|
||||
exports.OPS = pdfjsSharedUtil.OPS;
|
||||
exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
|
||||
exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
|
||||
exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
|
||||
exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
|
||||
exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
|
||||
|
|
|
@ -839,6 +839,25 @@ PDFJS.compatibilityChecked = true;
|
|||
};
|
||||
})();
|
||||
|
||||
// Provides support for Object.values in legacy browsers.
|
||||
// Support: IE.
|
||||
(function checkObjectValues() {
|
||||
if (Object.values) {
|
||||
return;
|
||||
}
|
||||
Object.values = require('core-js/fn/object/values');
|
||||
})();
|
||||
|
||||
// Provides support for Array.prototype.includes in legacy browsers.
|
||||
// Support: IE.
|
||||
(function checkArrayIncludes() {
|
||||
if (Array.prototype.includes) {
|
||||
return;
|
||||
}
|
||||
Array.prototype.includes = require('core-js/fn/array/includes');
|
||||
})();
|
||||
|
||||
|
||||
// Provides support for Number.isNaN in legacy browsers.
|
||||
// Support: IE.
|
||||
(function checkNumberIsNaN() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue