Merge pull request #8035 from Snuffleupagus/api-disableNativeImageDecoder

[api-minor] Add a `getDocument` parameter that allows disabling of the `NativeImageDecoder` (e.g. for use with Node.js)
This commit is contained in:
Tim van der Meij 2017-02-06 23:37:02 +01:00 committed by GitHub
commit d3ae5b38ce
3 changed files with 16 additions and 5 deletions

View file

@ -131,6 +131,10 @@ if (typeof PDFJSDev !== 'undefined' &&
* @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 - (optional) 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`.
*/
/**
@ -244,6 +248,7 @@ function getDocument(src, pdfDataRangeTransport,
}
params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
params.disableNativeImageDecoder = params.disableNativeImageDecoder === true;
if (!worker) {
// Worker was not provided -- creating and owning our own.
@ -304,6 +309,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
postMessageTransfers: getDefaultSetting('postMessageTransfers') &&
!isPostMessageTransfersDisabled,
docBaseUrl: source.docBaseUrl,
disableNativeImageDecoder: source.disableNativeImageDecoder,
}).then(function (workerId) {
if (worker.destroyed) {
throw new Error('Worker was destroyed');