|
|
@ -27,14 +27,15 @@ |
|
|
|
* above this value will not be drawn. Use -1 for no limit. |
|
|
|
* above this value will not be drawn. Use -1 for no limit. |
|
|
|
* @var {number} |
|
|
|
* @var {number} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize; |
|
|
|
PDFJS.maxImageSize = (PDFJS.maxImageSize === undefined ? |
|
|
|
|
|
|
|
-1 : PDFJS.maxImageSize); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The url of where the predefined Adobe CMaps are located. Include trailing |
|
|
|
* The url of where the predefined Adobe CMaps are located. Include trailing |
|
|
|
* slash. |
|
|
|
* slash. |
|
|
|
* @var {string} |
|
|
|
* @var {string} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl; |
|
|
|
PDFJS.cMapUrl = (PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl); |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
|
* By default fonts are converted to OpenType fonts and loaded via font face |
|
|
|
* By default fonts are converted to OpenType fonts and loaded via font face |
|
|
@ -42,16 +43,16 @@ PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl; |
|
|
|
* that constructs the glyphs with primitive path commands. |
|
|
|
* that constructs the glyphs with primitive path commands. |
|
|
|
* @var {boolean} |
|
|
|
* @var {boolean} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? |
|
|
|
PDFJS.disableFontFace = (PDFJS.disableFontFace === undefined ? |
|
|
|
false : PDFJS.disableFontFace; |
|
|
|
false : PDFJS.disableFontFace); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Path for image resources, mainly for annotation icons. Include trailing |
|
|
|
* Path for image resources, mainly for annotation icons. Include trailing |
|
|
|
* slash. |
|
|
|
* slash. |
|
|
|
* @var {string} |
|
|
|
* @var {string} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? |
|
|
|
PDFJS.imageResourcesPath = (PDFJS.imageResourcesPath === undefined ? |
|
|
|
'' : PDFJS.imageResourcesPath; |
|
|
|
'' : PDFJS.imageResourcesPath); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Disable the web worker and run all code on the main thread. This will happen |
|
|
|
* Disable the web worker and run all code on the main thread. This will happen |
|
|
@ -59,8 +60,8 @@ PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? |
|
|
|
* to workers. |
|
|
|
* to workers. |
|
|
|
* @var {boolean} |
|
|
|
* @var {boolean} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
PDFJS.disableWorker = PDFJS.disableWorker === undefined ? |
|
|
|
PDFJS.disableWorker = (PDFJS.disableWorker === undefined ? |
|
|
|
false : PDFJS.disableWorker; |
|
|
|
false : PDFJS.disableWorker); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Path and filename of the worker file. Required when the worker is enabled in |
|
|
|
* Path and filename of the worker file. Required when the worker is enabled in |
|
|
@ -68,7 +69,7 @@ PDFJS.disableWorker = PDFJS.disableWorker === undefined ? |
|
|
|
* loaded based on the location of the pdf.js file. |
|
|
|
* loaded based on the location of the pdf.js file. |
|
|
|
* @var {string} |
|
|
|
* @var {string} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc; |
|
|
|
PDFJS.workerSrc = (PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Disable range request loading of PDF files. When enabled and if the server |
|
|
|
* Disable range request loading of PDF files. When enabled and if the server |
|
|
@ -76,8 +77,8 @@ PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc; |
|
|
|
* Enabled (false) by default. |
|
|
|
* Enabled (false) by default. |
|
|
|
* @var {boolean} |
|
|
|
* @var {boolean} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
PDFJS.disableRange = PDFJS.disableRange === undefined ? |
|
|
|
PDFJS.disableRange = (PDFJS.disableRange === undefined ? |
|
|
|
false : PDFJS.disableRange; |
|
|
|
false : PDFJS.disableRange); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Disable pre-fetching of PDF file data. When range requests are enabled PDF.js |
|
|
|
* Disable pre-fetching of PDF file data. When range requests are enabled PDF.js |
|
|
@ -85,28 +86,28 @@ PDFJS.disableRange = PDFJS.disableRange === undefined ? |
|
|
|
* the current page. This default behavior can be disabled. |
|
|
|
* the current page. This default behavior can be disabled. |
|
|
|
* @var {boolean} |
|
|
|
* @var {boolean} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? |
|
|
|
PDFJS.disableAutoFetch = (PDFJS.disableAutoFetch === undefined ? |
|
|
|
false : PDFJS.disableAutoFetch; |
|
|
|
false : PDFJS.disableAutoFetch); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Enables special hooks for debugging PDF.js. |
|
|
|
* Enables special hooks for debugging PDF.js. |
|
|
|
* @var {boolean} |
|
|
|
* @var {boolean} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug; |
|
|
|
PDFJS.pdfBug = (PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Enables transfer usage in postMessage for ArrayBuffers. |
|
|
|
* Enables transfer usage in postMessage for ArrayBuffers. |
|
|
|
* @var {boolean} |
|
|
|
* @var {boolean} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? |
|
|
|
PDFJS.postMessageTransfers = (PDFJS.postMessageTransfers === undefined ? |
|
|
|
true : PDFJS.postMessageTransfers; |
|
|
|
true : PDFJS.postMessageTransfers); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Disables URL.createObjectURL usage. |
|
|
|
* Disables URL.createObjectURL usage. |
|
|
|
* @var {boolean} |
|
|
|
* @var {boolean} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? |
|
|
|
PDFJS.disableCreateObjectURL = (PDFJS.disableCreateObjectURL === undefined ? |
|
|
|
false : PDFJS.disableCreateObjectURL; |
|
|
|
false : PDFJS.disableCreateObjectURL); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Controls the logging level. |
|
|
|
* Controls the logging level. |
|
|
@ -116,8 +117,8 @@ PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? |
|
|
|
* - infos |
|
|
|
* - infos |
|
|
|
* @var {number} |
|
|
|
* @var {number} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
PDFJS.verbosity = PDFJS.verbosity === undefined ? |
|
|
|
PDFJS.verbosity = (PDFJS.verbosity === undefined ? |
|
|
|
PDFJS.VERBOSITY_LEVELS.warnings : PDFJS.verbosity; |
|
|
|
PDFJS.VERBOSITY_LEVELS.warnings : PDFJS.verbosity); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Document initialization / loading parameters object. |
|
|
|
* Document initialization / loading parameters object. |
|
|
@ -172,8 +173,9 @@ PDFJS.getDocument = function getDocument(source, |
|
|
|
'string or a parameter object'); |
|
|
|
'string or a parameter object'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!source.url && !source.data) |
|
|
|
if (!source.url && !source.data) { |
|
|
|
error('Invalid parameter array, need either .data or .url'); |
|
|
|
error('Invalid parameter array, need either .data or .url'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// copy/use all keys as is except 'url' -- full path is required
|
|
|
|
// copy/use all keys as is except 'url' -- full path is required
|
|
|
|
var params = {}; |
|
|
|
var params = {}; |
|
|
@ -187,8 +189,8 @@ PDFJS.getDocument = function getDocument(source, |
|
|
|
|
|
|
|
|
|
|
|
workerInitializedPromise = new PDFJS.LegacyPromise(); |
|
|
|
workerInitializedPromise = new PDFJS.LegacyPromise(); |
|
|
|
workerReadyPromise = new PDFJS.LegacyPromise(); |
|
|
|
workerReadyPromise = new PDFJS.LegacyPromise(); |
|
|
|
transport = new WorkerTransport(workerInitializedPromise, |
|
|
|
transport = new WorkerTransport(workerInitializedPromise, workerReadyPromise, |
|
|
|
workerReadyPromise, pdfDataRangeTransport, progressCallback); |
|
|
|
pdfDataRangeTransport, progressCallback); |
|
|
|
workerInitializedPromise.then(function transportInitialized() { |
|
|
|
workerInitializedPromise.then(function transportInitialized() { |
|
|
|
transport.passwordCallback = passwordCallback; |
|
|
|
transport.passwordCallback = passwordCallback; |
|
|
|
transport.fetchDocument(params); |
|
|
|
transport.fetchDocument(params); |
|
|
@ -287,7 +289,7 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() { |
|
|
|
var metadata = this.pdfInfo.metadata; |
|
|
|
var metadata = this.pdfInfo.metadata; |
|
|
|
promise.resolve({ |
|
|
|
promise.resolve({ |
|
|
|
info: info, |
|
|
|
info: info, |
|
|
|
metadata: metadata ? new PDFJS.Metadata(metadata) : null |
|
|
|
metadata: (metadata ? new PDFJS.Metadata(metadata) : null) |
|
|
|
}); |
|
|
|
}); |
|
|
|
return promise; |
|
|
|
return promise; |
|
|
|
}, |
|
|
|
}, |
|
|
@ -387,8 +389,9 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
* with transforms required for rendering. |
|
|
|
* with transforms required for rendering. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
getViewport: function PDFPageProxy_getViewport(scale, rotate) { |
|
|
|
getViewport: function PDFPageProxy_getViewport(scale, rotate) { |
|
|
|
if (arguments.length < 2) |
|
|
|
if (arguments.length < 2) { |
|
|
|
rotate = this.rotate; |
|
|
|
rotate = this.rotate; |
|
|
|
|
|
|
|
} |
|
|
|
return new PDFJS.PageViewport(this.view, scale, rotate, 0, 0); |
|
|
|
return new PDFJS.PageViewport(this.view, scale, rotate, 0, 0); |
|
|
|
}, |
|
|
|
}, |
|
|
|
/** |
|
|
|
/** |
|
|
@ -396,8 +399,9 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
* annotation objects. |
|
|
|
* annotation objects. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
getAnnotations: function PDFPageProxy_getAnnotations() { |
|
|
|
getAnnotations: function PDFPageProxy_getAnnotations() { |
|
|
|
if (this.annotationsPromise) |
|
|
|
if (this.annotationsPromise) { |
|
|
|
return this.annotationsPromise; |
|
|
|
return this.annotationsPromise; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var promise = new PDFJS.LegacyPromise(); |
|
|
|
var promise = new PDFJS.LegacyPromise(); |
|
|
|
this.annotationsPromise = promise; |
|
|
|
this.annotationsPromise = promise; |
|
|
@ -429,9 +433,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
// this call to render.
|
|
|
|
// this call to render.
|
|
|
|
this.pendingDestroy = false; |
|
|
|
this.pendingDestroy = false; |
|
|
|
|
|
|
|
|
|
|
|
var renderingIntent = 'intent' in params ? |
|
|
|
var renderingIntent = ('intent' in params ? |
|
|
|
(params.intent == 'print' ? 'print' : 'display') : |
|
|
|
(params.intent == 'print' ? 'print' : 'display') : 'display'); |
|
|
|
'display'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.intentStates[renderingIntent]) { |
|
|
|
if (!this.intentStates[renderingIntent]) { |
|
|
|
this.intentStates[renderingIntent] = {}; |
|
|
|
this.intentStates[renderingIntent] = {}; |
|
|
@ -457,7 +460,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var internalRenderTask = new InternalRenderTask(complete, params, |
|
|
|
var internalRenderTask = new InternalRenderTask(complete, params, |
|
|
|
this.objs, this.commonObjs, |
|
|
|
this.objs, |
|
|
|
|
|
|
|
this.commonObjs, |
|
|
|
intentState.operatorList, |
|
|
|
intentState.operatorList, |
|
|
|
this.pageNumber); |
|
|
|
this.pageNumber); |
|
|
|
if (!intentState.renderTasks) { |
|
|
|
if (!intentState.renderTasks) { |
|
|
@ -535,8 +539,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
if (!this.pendingDestroy || |
|
|
|
if (!this.pendingDestroy || |
|
|
|
Object.keys(this.intentStates).some(function(intent) { |
|
|
|
Object.keys(this.intentStates).some(function(intent) { |
|
|
|
var intentState = this.intentStates[intent]; |
|
|
|
var intentState = this.intentStates[intent]; |
|
|
|
return intentState.renderTasks.length !== 0 || |
|
|
|
return (intentState.renderTasks.length !== 0 || |
|
|
|
intentState.receivingOperatorList; |
|
|
|
intentState.receivingOperatorList); |
|
|
|
}, this)) { |
|
|
|
}, this)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -815,8 +819,9 @@ var WorkerTransport = (function WorkerTransportClosure() { |
|
|
|
messageHandler.on('commonobj', function transportObj(data) { |
|
|
|
messageHandler.on('commonobj', function transportObj(data) { |
|
|
|
var id = data[0]; |
|
|
|
var id = data[0]; |
|
|
|
var type = data[1]; |
|
|
|
var type = data[1]; |
|
|
|
if (this.commonObjs.hasData(id)) |
|
|
|
if (this.commonObjs.hasData(id)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch (type) { |
|
|
|
switch (type) { |
|
|
|
case 'Font': |
|
|
|
case 'Font': |
|
|
@ -893,17 +898,19 @@ var WorkerTransport = (function WorkerTransportClosure() { |
|
|
|
messageHandler.on('PageError', function transportError(data, intent) { |
|
|
|
messageHandler.on('PageError', function transportError(data, intent) { |
|
|
|
var page = this.pageCache[data.pageNum - 1]; |
|
|
|
var page = this.pageCache[data.pageNum - 1]; |
|
|
|
var intentState = page.intentStates[intent]; |
|
|
|
var intentState = page.intentStates[intent]; |
|
|
|
if (intentState.displayReadyPromise) |
|
|
|
if (intentState.displayReadyPromise) { |
|
|
|
intentState.displayReadyPromise.reject(data.error); |
|
|
|
intentState.displayReadyPromise.reject(data.error); |
|
|
|
else |
|
|
|
} else { |
|
|
|
error(data.error); |
|
|
|
error(data.error); |
|
|
|
|
|
|
|
} |
|
|
|
}, this); |
|
|
|
}, this); |
|
|
|
|
|
|
|
|
|
|
|
messageHandler.on('JpegDecode', function(data, deferred) { |
|
|
|
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) { |
|
|
|
error('Only 3 component or 1 component can be returned'); |
|
|
|
error('Only 3 component or 1 component can be returned'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var img = new Image(); |
|
|
|
var img = new Image(); |
|
|
|
img.onload = (function messageHandler_onloadClosure() { |
|
|
|
img.onload = (function messageHandler_onloadClosure() { |
|
|
@ -963,8 +970,9 @@ 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.LegacyPromise(); |
|
|
|
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 }); |
|
|
@ -1033,8 +1041,9 @@ var PDFObjects = (function PDFObjectsClosure() { |
|
|
|
* Ensures there is an object defined for `objId`. |
|
|
|
* Ensures there is an object defined for `objId`. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
ensureObj: function PDFObjects_ensureObj(objId) { |
|
|
|
ensureObj: function PDFObjects_ensureObj(objId) { |
|
|
|
if (this.objs[objId]) |
|
|
|
if (this.objs[objId]) { |
|
|
|
return this.objs[objId]; |
|
|
|
return this.objs[objId]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var obj = { |
|
|
|
var obj = { |
|
|
|
promise: new LegacyPromise(), |
|
|
|
promise: new LegacyPromise(), |
|
|
@ -1069,8 +1078,9 @@ var PDFObjects = (function PDFObjectsClosure() { |
|
|
|
|
|
|
|
|
|
|
|
// If there isn't an object yet or the object isn't resolved, then the
|
|
|
|
// If there isn't an object yet or the object isn't resolved, then the
|
|
|
|
// data isn't ready yet!
|
|
|
|
// data isn't ready yet!
|
|
|
|
if (!obj || !obj.resolved) |
|
|
|
if (!obj || !obj.resolved) { |
|
|
|
error('Requesting object that isn\'t resolved yet ' + objId); |
|
|
|
error('Requesting object that isn\'t resolved yet ' + objId); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return obj.data; |
|
|
|
return obj.data; |
|
|
|
}, |
|
|
|
}, |
|
|
|