Bug 1488420 - Update pdf.js to version 2.0.815. r=bdahl
authorRyan VanderMeulen <ryanvm@gmail.com>
Thu, 06 Sep 2018 08:28:26 -0400
changeset 493502 2eb928e685a38d3a4763c24ec5fdafb9dfa50d5a
parent 493501 73234821ad08dca27e4fec2ab409f8254aad12ec
child 493503 1c622661cfe203598435cf9730b2a748c556a9ae
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbdahl
bugs1488420
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1488420 - Update pdf.js to version 2.0.815. r=bdahl
browser/extensions/pdfjs/README.mozilla
browser/extensions/pdfjs/content/PdfJsDefaultPreferences.jsm
browser/extensions/pdfjs/content/build/pdf.js
browser/extensions/pdfjs/content/build/pdf.worker.js
browser/extensions/pdfjs/content/web/viewer.js
browser/extensions/pdfjs/moz.yaml
--- a/browser/extensions/pdfjs/README.mozilla
+++ b/browser/extensions/pdfjs/README.mozilla
@@ -1,5 +1,5 @@
 This is the PDF.js project output, https://github.com/mozilla/pdf.js
 
-Current extension version is: 2.0.775
+Current extension version is: 2.0.815
 
-Taken from upstream commit: 20cd1b35
+Taken from upstream commit: d6927376
--- a/browser/extensions/pdfjs/content/PdfJsDefaultPreferences.jsm
+++ b/browser/extensions/pdfjs/content/PdfJsDefaultPreferences.jsm
@@ -1,43 +1,46 @@
-/* Copyright 2017 Mozilla Foundation
+/* Copyright 2018 Mozilla Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
+/* eslint-disable */
+
 //
-// THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT MANUALLY!
+// THIS FILE IS GENERATED AUTOMATICALLY, DO NOT EDIT MANUALLY!
 //
 
 "use strict";
 var EXPORTED_SYMBOLS = ["PdfJsDefaultPreferences"];
 var PdfJsDefaultPreferences = Object.freeze({
  "showPreviousViewOnLoad": true,
  "defaultZoomValue": "",
  "sidebarViewOnLoad": 0,
  "cursorToolOnLoad": 0,
  "enableWebGL": false,
+ "eventBusDispatchToDOM": false,
  "pdfBugEnabled": false,
  "disableRange": false,
  "disableStream": false,
  "disableAutoFetch": false,
  "disableFontFace": false,
  "textLayerMode": 1,
  "useOnlyCssZoom": false,
  "externalLinkTarget": 0,
  "renderer": "canvas",
  "renderInteractiveForms": false,
  "enablePrintAutoRotate": false,
  "disablePageMode": false,
  "disablePageLabels": false,
  "scrollModeOnLoad": 0,
- "spreadModeOnLoad": 0,
+ "spreadModeOnLoad": 0
 });
--- a/browser/extensions/pdfjs/content/build/pdf.js
+++ b/browser/extensions/pdfjs/content/build/pdf.js
@@ -1,13 +1,13 @@
 /**
  * @licstart The following is the entire license notice for the
  * Javascript code in this page
  *
- * Copyright 2017 Mozilla Foundation
+ * Copyright 2018 Mozilla Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
@@ -118,18 +118,18 @@ return /******/ (function(modules) { // 
 /************************************************************************/
 /******/ ([
 /* 0 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-var pdfjsVersion = '2.0.775';
-var pdfjsBuild = '20cd1b35';
+var pdfjsVersion = '2.0.815';
+var pdfjsBuild = 'd6927376';
 var pdfjsSharedUtil = __w_pdfjs_require__(1);
 var pdfjsDisplayAPI = __w_pdfjs_require__(7);
 var pdfjsDisplayTextLayer = __w_pdfjs_require__(19);
 var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(20);
 var pdfjsDisplayDOMUtils = __w_pdfjs_require__(8);
 var pdfjsDisplaySVG = __w_pdfjs_require__(21);
 let pdfjsDisplayWorkerOptions = __w_pdfjs_require__(13);
 let pdfjsDisplayAPICompatibility = __w_pdfjs_require__(10);
@@ -172,30 +172,40 @@ exports.apiCompatibilityParams = pdfjsDi
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
-exports.unreachable = exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.URL = exports.ReadableStream = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isSpace = exports.isString = exports.isNum = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.info = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.getInheritableProperty = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.FormatError = exports.XRefParseException = exports.toRomanNumerals = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PasswordResponses = exports.PasswordException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined;
+exports.unreachable = exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.URL = exports.ReadableStream = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isSpace = exports.isString = exports.isNum = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.info = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.getInheritableProperty = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.FormatError = exports.XRefParseException = exports.toRomanNumerals = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined;
 
 __w_pdfjs_require__(2);
 
 var _streams_polyfill = __w_pdfjs_require__(4);
 
 var _url_polyfill = __w_pdfjs_require__(6);
 
 var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
 const NativeImageDecoding = {
   NONE: 'none',
   DECODE: 'decode',
   DISPLAY: 'display'
 };
+const PermissionFlag = {
+  PRINT: 0x04,
+  MODIFY_CONTENTS: 0x08,
+  COPY: 0x10,
+  MODIFY_ANNOTATIONS: 0x20,
+  FILL_INTERACTIVE_FORMS: 0x100,
+  COPY_FOR_ACCESSIBILITY: 0x200,
+  ASSEMBLE: 0x400,
+  PRINT_HIGH_QUALITY: 0x800
+};
 var TextRenderingMode = {
   FILL: 0,
   STROKE: 1,
   FILL_STROKE: 2,
   INVISIBLE: 3,
   FILL_ADD_TO_PATH: 4,
   STROKE_ADD_TO_PATH: 5,
   FILL_STROKE_ADD_TO_PATH: 6,
@@ -908,16 +918,17 @@ exports.ImageKind = ImageKind;
 exports.CMapCompressionType = CMapCompressionType;
 exports.AbortException = AbortException;
 exports.InvalidPDFException = InvalidPDFException;
 exports.MissingDataException = MissingDataException;
 exports.MissingPDFException = MissingPDFException;
 exports.NativeImageDecoding = NativeImageDecoding;
 exports.PasswordException = PasswordException;
 exports.PasswordResponses = PasswordResponses;
+exports.PermissionFlag = PermissionFlag;
 exports.StreamType = StreamType;
 exports.TextRenderingMode = TextRenderingMode;
 exports.UnexpectedResponseException = UnexpectedResponseException;
 exports.UnknownErrorException = UnknownErrorException;
 exports.Util = Util;
 exports.toRomanNumerals = toRomanNumerals;
 exports.XRefParseException = XRefParseException;
 exports.FormatError = FormatError;
@@ -4210,17 +4221,17 @@ function _fetchDocument(worker, source, 
     return Promise.reject(new Error('Worker was destroyed'));
   }
   if (pdfDataRangeTransport) {
     source.length = pdfDataRangeTransport.length;
     source.initialData = pdfDataRangeTransport.initialData;
   }
   return worker.messageHandler.sendWithPromise('GetDocRequest', {
     docId,
-    apiVersion: '2.0.775',
+    apiVersion: '2.0.815',
     source: {
       data: source.data,
       url: source.url,
       password: source.password,
       disableAutoFetch: source.disableAutoFetch,
       rangeChunkSize: source.rangeChunkSize,
       length: source.length
     },
@@ -4318,80 +4329,80 @@ var PDFDataRangeTransport = function pdf
     },
     requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
       (0, _util.unreachable)('Abstract method PDFDataRangeTransport.requestDataRange');
     },
     abort: function PDFDataRangeTransport_abort() {}
   };
   return PDFDataRangeTransport;
 }();
-var PDFDocumentProxy = function PDFDocumentProxyClosure() {
-  function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
-    this._pdfInfo = pdfInfo;
-    this.transport = transport;
+class PDFDocumentProxy {
+  constructor(pdfInfo, transport, loadingTask) {
     this.loadingTask = loadingTask;
-  }
-  PDFDocumentProxy.prototype = {
-    get numPages() {
-      return this._pdfInfo.numPages;
-    },
-    get fingerprint() {
-      return this._pdfInfo.fingerprint;
-    },
-    getPage(pageNumber) {
-      return this.transport.getPage(pageNumber);
-    },
-    getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
-      return this.transport.getPageIndex(ref);
-    },
-    getDestinations: function PDFDocumentProxy_getDestinations() {
-      return this.transport.getDestinations();
-    },
-    getDestination: function PDFDocumentProxy_getDestination(id) {
-      return this.transport.getDestination(id);
-    },
-    getPageLabels: function PDFDocumentProxy_getPageLabels() {
-      return this.transport.getPageLabels();
-    },
-    getPageMode() {
-      return this.transport.getPageMode();
-    },
-    getAttachments: function PDFDocumentProxy_getAttachments() {
-      return this.transport.getAttachments();
-    },
-    getJavaScript() {
-      return this.transport.getJavaScript();
-    },
-    getOutline: function PDFDocumentProxy_getOutline() {
-      return this.transport.getOutline();
-    },
-    getMetadata: function PDFDocumentProxy_getMetadata() {
-      return this.transport.getMetadata();
-    },
-    getData: function PDFDocumentProxy_getData() {
-      return this.transport.getData();
-    },
-    getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
-      return this.transport.downloadInfoCapability.promise;
-    },
-    getStats: function PDFDocumentProxy_getStats() {
-      return this.transport.getStats();
-    },
-    cleanup: function PDFDocumentProxy_cleanup() {
-      this.transport.startCleanup();
-    },
-    destroy: function PDFDocumentProxy_destroy() {
-      return this.loadingTask.destroy();
-    },
-    get loadingParams() {
-      return this.transport.loadingParams;
-    }
-  };
-  return PDFDocumentProxy;
-}();
+    this._pdfInfo = pdfInfo;
+    this._transport = transport;
+  }
+  get numPages() {
+    return this._pdfInfo.numPages;
+  }
+  get fingerprint() {
+    return this._pdfInfo.fingerprint;
+  }
+  getPage(pageNumber) {
+    return this._transport.getPage(pageNumber);
+  }
+  getPageIndex(ref) {
+    return this._transport.getPageIndex(ref);
+  }
+  getDestinations() {
+    return this._transport.getDestinations();
+  }
+  getDestination(id) {
+    return this._transport.getDestination(id);
+  }
+  getPageLabels() {
+    return this._transport.getPageLabels();
+  }
+  getPageMode() {
+    return this._transport.getPageMode();
+  }
+  getAttachments() {
+    return this._transport.getAttachments();
+  }
+  getJavaScript() {
+    return this._transport.getJavaScript();
+  }
+  getOutline() {
+    return this._transport.getOutline();
+  }
+  getPermissions() {
+    return this._transport.getPermissions();
+  }
+  getMetadata() {
+    return this._transport.getMetadata();
+  }
+  getData() {
+    return this._transport.getData();
+  }
+  getDownloadInfo() {
+    return this._transport.downloadInfoCapability.promise;
+  }
+  getStats() {
+    return this._transport.getStats();
+  }
+  cleanup() {
+    this._transport.startCleanup();
+  }
+  destroy() {
+    return this.loadingTask.destroy();
+  }
+  get loadingParams() {
+    return this._transport.loadingParams;
+  }
+}
 var PDFPageProxy = function PDFPageProxyClosure() {
   function PDFPageProxy(pageIndex, pageInfo, transport, pdfBug = false) {
     this.pageIndex = pageIndex;
     this._pageInfo = pageInfo;
     this.transport = transport;
     this._stats = pdfBug ? new _dom_utils.StatTimer() : _dom_utils.DummyStatTimer;
     this._pdfBug = pdfBug;
     this.commonObjs = transport.commonObjs;
@@ -4895,18 +4906,18 @@ var PDFWorker = function PDFWorkerClosur
     }
     return new PDFWorker(params);
   };
   PDFWorker.getWorkerSrc = function () {
     return getWorkerSrc();
   };
   return PDFWorker;
 }();
-var WorkerTransport = function WorkerTransportClosure() {
-  function WorkerTransport(messageHandler, loadingTask, networkStream, params) {
+class WorkerTransport {
+  constructor(messageHandler, loadingTask, networkStream, params) {
     this.messageHandler = messageHandler;
     this.loadingTask = loadingTask;
     this.commonObjs = new PDFObjects();
     this.fontLoader = new _font_loader.FontLoader(loadingTask.docId);
     this._params = params;
     this.CMapReaderFactory = new params.CMapReaderFactory({
       baseUrl: params.cMapUrl,
       isCompressed: params.cMapPacked
@@ -4917,456 +4928,440 @@ var WorkerTransport = function WorkerTra
     this._networkStream = networkStream;
     this._fullReader = null;
     this._lastProgress = null;
     this.pageCache = [];
     this.pagePromises = [];
     this.downloadInfoCapability = (0, _util.createPromiseCapability)();
     this.setupMessageHandler();
   }
-  WorkerTransport.prototype = {
-    destroy: function WorkerTransport_destroy() {
-      if (this.destroyCapability) {
-        return this.destroyCapability.promise;
-      }
-      this.destroyed = true;
-      this.destroyCapability = (0, _util.createPromiseCapability)();
-      if (this._passwordCapability) {
-        this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
-      }
-      var waitOn = [];
-      this.pageCache.forEach(function (page) {
-        if (page) {
-          waitOn.push(page._destroy());
-        }
-      });
-      this.pageCache = [];
-      this.pagePromises = [];
-      var terminated = this.messageHandler.sendWithPromise('Terminate', null);
-      waitOn.push(terminated);
-      Promise.all(waitOn).then(() => {
-        this.fontLoader.clear();
-        if (this._networkStream) {
-          this._networkStream.cancelAllRequests();
-        }
-        if (this.messageHandler) {
-          this.messageHandler.destroy();
-          this.messageHandler = null;
-        }
-        this.destroyCapability.resolve();
-      }, this.destroyCapability.reject);
+  destroy() {
+    if (this.destroyCapability) {
       return this.destroyCapability.promise;
-    },
-    setupMessageHandler: function WorkerTransport_setupMessageHandler() {
-      var messageHandler = this.messageHandler;
-      var loadingTask = this.loadingTask;
-      messageHandler.on('GetReader', function (data, sink) {
-        (0, _util.assert)(this._networkStream);
-        this._fullReader = this._networkStream.getFullReader();
-        this._fullReader.onProgress = evt => {
-          this._lastProgress = {
-            loaded: evt.loaded,
-            total: evt.total
-          };
+    }
+    this.destroyed = true;
+    this.destroyCapability = (0, _util.createPromiseCapability)();
+    if (this._passwordCapability) {
+      this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
+    }
+    const waitOn = [];
+    this.pageCache.forEach(function (page) {
+      if (page) {
+        waitOn.push(page._destroy());
+      }
+    });
+    this.pageCache = [];
+    this.pagePromises = [];
+    const terminated = this.messageHandler.sendWithPromise('Terminate', null);
+    waitOn.push(terminated);
+    Promise.all(waitOn).then(() => {
+      this.fontLoader.clear();
+      if (this._networkStream) {
+        this._networkStream.cancelAllRequests();
+      }
+      if (this.messageHandler) {
+        this.messageHandler.destroy();
+        this.messageHandler = null;
+      }
+      this.destroyCapability.resolve();
+    }, this.destroyCapability.reject);
+    return this.destroyCapability.promise;
+  }
+  setupMessageHandler() {
+    const { messageHandler, loadingTask } = this;
+    messageHandler.on('GetReader', function (data, sink) {
+      (0, _util.assert)(this._networkStream);
+      this._fullReader = this._networkStream.getFullReader();
+      this._fullReader.onProgress = evt => {
+        this._lastProgress = {
+          loaded: evt.loaded,
+          total: evt.total
         };
-        sink.onPull = () => {
-          this._fullReader.read().then(function ({ value, done }) {
-            if (done) {
-              sink.close();
-              return;
+      };
+      sink.onPull = () => {
+        this._fullReader.read().then(function ({ value, done }) {
+          if (done) {
+            sink.close();
+            return;
+          }
+          (0, _util.assert)((0, _util.isArrayBuffer)(value));
+          sink.enqueue(new Uint8Array(value), 1, [value]);
+        }).catch(reason => {
+          sink.error(reason);
+        });
+      };
+      sink.onCancel = reason => {
+        this._fullReader.cancel(reason);
+      };
+    }, this);
+    messageHandler.on('ReaderHeadersReady', function (data) {
+      const headersCapability = (0, _util.createPromiseCapability)();
+      const fullReader = this._fullReader;
+      fullReader.headersReady.then(() => {
+        if (!fullReader.isStreamingSupported || !fullReader.isRangeSupported) {
+          if (this._lastProgress) {
+            if (loadingTask.onProgress) {
+              loadingTask.onProgress(this._lastProgress);
+            }
+          }
+          fullReader.onProgress = evt => {
+            if (loadingTask.onProgress) {
+              loadingTask.onProgress({
+                loaded: evt.loaded,
+                total: evt.total
+              });
             }
-            (0, _util.assert)((0, _util.isArrayBuffer)(value));
-            sink.enqueue(new Uint8Array(value), 1, [value]);
-          }).catch(reason => {
-            sink.error(reason);
-          });
-        };
-        sink.onCancel = reason => {
-          this._fullReader.cancel(reason);
+          };
+        }
+        headersCapability.resolve({
+          isStreamingSupported: fullReader.isStreamingSupported,
+          isRangeSupported: fullReader.isRangeSupported,
+          contentLength: fullReader.contentLength
+        });
+      }, headersCapability.reject);
+      return headersCapability.promise;
+    }, this);
+    messageHandler.on('GetRangeReader', function (data, sink) {
+      (0, _util.assert)(this._networkStream);
+      const rangeReader = this._networkStream.getRangeReader(data.begin, data.end);
+      sink.onPull = () => {
+        rangeReader.read().then(function ({ value, done }) {
+          if (done) {
+            sink.close();
+            return;
+          }
+          (0, _util.assert)((0, _util.isArrayBuffer)(value));
+          sink.enqueue(new Uint8Array(value), 1, [value]);
+        }).catch(reason => {
+          sink.error(reason);
+        });
+      };
+      sink.onCancel = reason => {
+        rangeReader.cancel(reason);
+      };
+    }, this);
+    messageHandler.on('GetDoc', function ({ pdfInfo }) {
+      this.numPages = pdfInfo.numPages;
+      this.pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
+      loadingTask._capability.resolve(this.pdfDocument);
+    }, this);
+    messageHandler.on('PasswordRequest', function (exception) {
+      this._passwordCapability = (0, _util.createPromiseCapability)();
+      if (loadingTask.onPassword) {
+        const updatePassword = password => {
+          this._passwordCapability.resolve({ password });
         };
-      }, this);
-      messageHandler.on('ReaderHeadersReady', function (data) {
-        let headersCapability = (0, _util.createPromiseCapability)();
-        let fullReader = this._fullReader;
-        fullReader.headersReady.then(() => {
-          if (!fullReader.isStreamingSupported || !fullReader.isRangeSupported) {
-            if (this._lastProgress) {
-              let loadingTask = this.loadingTask;
-              if (loadingTask.onProgress) {
-                loadingTask.onProgress(this._lastProgress);
-              }
-            }
-            fullReader.onProgress = evt => {
-              let loadingTask = this.loadingTask;
-              if (loadingTask.onProgress) {
-                loadingTask.onProgress({
-                  loaded: evt.loaded,
-                  total: evt.total
-                });
+        try {
+          loadingTask.onPassword(updatePassword, exception.code);
+        } catch (ex) {
+          this._passwordCapability.reject(ex);
+        }
+      } else {
+        this._passwordCapability.reject(new _util.PasswordException(exception.message, exception.code));
+      }
+      return this._passwordCapability.promise;
+    }, this);
+    messageHandler.on('PasswordException', function (exception) {
+      loadingTask._capability.reject(new _util.PasswordException(exception.message, exception.code));
+    }, this);
+    messageHandler.on('InvalidPDF', function (exception) {
+      loadingTask._capability.reject(new _util.InvalidPDFException(exception.message));
+    }, this);
+    messageHandler.on('MissingPDF', function (exception) {
+      loadingTask._capability.reject(new _util.MissingPDFException(exception.message));
+    }, this);
+    messageHandler.on('UnexpectedResponse', function (exception) {
+      loadingTask._capability.reject(new _util.UnexpectedResponseException(exception.message, exception.status));
+    }, this);
+    messageHandler.on('UnknownError', function (exception) {
+      loadingTask._capability.reject(new _util.UnknownErrorException(exception.message, exception.details));
+    }, this);
+    messageHandler.on('DataLoaded', function (data) {
+      this.downloadInfoCapability.resolve(data);
+    }, this);
+    messageHandler.on('StartRenderPage', function (data) {
+      if (this.destroyed) {
+        return;
+      }
+      const page = this.pageCache[data.pageIndex];
+      page._stats.timeEnd('Page Request');
+      page._startRenderPage(data.transparency, data.intent);
+    }, this);
+    messageHandler.on('RenderPageChunk', function (data) {
+      if (this.destroyed) {
+        return;
+      }
+      const page = this.pageCache[data.pageIndex];
+      page._renderPageChunk(data.operatorList, data.intent);
+    }, this);
+    messageHandler.on('commonobj', function (data) {
+      if (this.destroyed) {
+        return;
+      }
+      const [id, type, exportedData] = data;
+      if (this.commonObjs.hasData(id)) {
+        return;
+      }
+      switch (type) {
+        case 'Font':
+          const params = this._params;
+          if ('error' in exportedData) {
+            const exportedError = exportedData.error;
+            (0, _util.warn)(`Error during font loading: ${exportedError}`);
+            this.commonObjs.resolve(id, exportedError);
+            break;
+          }
+          let fontRegistry = null;
+          if (params.pdfBug && _global_scope2.default.FontInspector && _global_scope2.default.FontInspector.enabled) {
+            fontRegistry = {
+              registerFont(font, url) {
+                _global_scope2.default['FontInspector'].fontAdded(font, url);
               }
             };
           }
-          headersCapability.resolve({
-            isStreamingSupported: fullReader.isStreamingSupported,
-            isRangeSupported: fullReader.isRangeSupported,
-            contentLength: fullReader.contentLength
+          const font = new _font_loader.FontFaceObject(exportedData, {
+            isEvalSupported: params.isEvalSupported,
+            disableFontFace: params.disableFontFace,
+            ignoreErrors: params.ignoreErrors,
+            onUnsupportedFeature: this._onUnsupportedFeature.bind(this),
+            fontRegistry
+          });
+          const fontReady = fontObjs => {
+            this.commonObjs.resolve(id, font);
+          };
+          this.fontLoader.bind([font], fontReady);
+          break;
+        case 'FontPath':
+          this.commonObjs.resolve(id, exportedData);
+          break;
+        default:
+          throw new Error(`Got unknown common object type ${type}`);
+      }
+    }, this);
+    messageHandler.on('obj', function (data) {
+      if (this.destroyed) {
+        return;
+      }
+      const [id, pageIndex, type, imageData] = data;
+      const pageProxy = this.pageCache[pageIndex];
+      if (pageProxy.objs.hasData(id)) {
+        return;
+      }
+      switch (type) {
+        case 'JpegStream':
+          return new Promise((resolve, reject) => {
+            const img = new Image();
+            img.onload = function () {
+              resolve(img);
+            };
+            img.onerror = function () {
+              reject(new Error('Error during JPEG image loading'));
+            };
+            img.src = imageData;
+          }).then(img => {
+            pageProxy.objs.resolve(id, img);
           });
-        }, headersCapability.reject);
-        return headersCapability.promise;
-      }, this);
-      messageHandler.on('GetRangeReader', function (data, sink) {
-        (0, _util.assert)(this._networkStream);
-        let _rangeReader = this._networkStream.getRangeReader(data.begin, data.end);
-        sink.onPull = () => {
-          _rangeReader.read().then(function ({ value, done }) {
-            if (done) {
-              sink.close();
-              return;
+        case 'Image':
+          pageProxy.objs.resolve(id, imageData);
+          const MAX_IMAGE_SIZE_TO_STORE = 8000000;
+          if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
+            pageProxy.cleanupAfterRender = true;
+          }
+          break;
+        default:
+          throw new Error(`Got unknown object type ${type}`);
+      }
+    }, this);
+    messageHandler.on('DocProgress', function (data) {
+      if (this.destroyed) {
+        return;
+      }
+      if (loadingTask.onProgress) {
+        loadingTask.onProgress({
+          loaded: data.loaded,
+          total: data.total
+        });
+      }
+    }, this);
+    messageHandler.on('PageError', function (data) {
+      if (this.destroyed) {
+        return;
+      }
+      const page = this.pageCache[data.pageNum - 1];
+      const intentState = page.intentStates[data.intent];
+      if (intentState.displayReadyCapability) {
+        intentState.displayReadyCapability.reject(data.error);
+      } else {
+        throw new Error(data.error);
+      }
+      if (intentState.operatorList) {
+        intentState.operatorList.lastChunk = true;
+        for (let i = 0; i < intentState.renderTasks.length; i++) {
+          intentState.renderTasks[i].operatorListChanged();
+        }
+      }
+    }, this);
+    messageHandler.on('UnsupportedFeature', this._onUnsupportedFeature, this);
+    messageHandler.on('JpegDecode', function (data) {
+      if (this.destroyed) {
+        return Promise.reject(new Error('Worker was destroyed'));
+      }
+      if (typeof document === 'undefined') {
+        return Promise.reject(new Error('"document" is not defined.'));
+      }
+      const [imageUrl, components] = data;
+      if (components !== 3 && components !== 1) {
+        return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
+      }
+      return new Promise(function (resolve, reject) {
+        const img = new Image();
+        img.onload = function () {
+          const width = img.width;
+          const height = img.height;
+          const size = width * height;
+          const rgbaLength = size * 4;
+          const buf = new Uint8ClampedArray(size * components);
+          const tmpCanvas = document.createElement('canvas');
+          tmpCanvas.width = width;
+          tmpCanvas.height = height;
+          const tmpCtx = tmpCanvas.getContext('2d');
+          tmpCtx.drawImage(img, 0, 0);
+          const data = tmpCtx.getImageData(0, 0, width, height).data;
+          if (components === 3) {
+            for (let i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
+              buf[j] = data[i];
+              buf[j + 1] = data[i + 1];
+              buf[j + 2] = data[i + 2];
             }
-            (0, _util.assert)((0, _util.isArrayBuffer)(value));
-            sink.enqueue(new Uint8Array(value), 1, [value]);
-          }).catch(reason => {
-            sink.error(reason);
+          } else if (components === 1) {
+            for (let i = 0, j = 0; i < rgbaLength; i += 4, j++) {
+              buf[j] = data[i];
+            }
+          }
+          resolve({
+            data: buf,
+            width,
+            height
           });
         };
-        sink.onCancel = reason => {
-          _rangeReader.cancel(reason);
+        img.onerror = function () {
+          reject(new Error('JpegDecode failed to load image'));
         };
-      }, this);
-      messageHandler.on('GetDoc', function transportDoc({ pdfInfo }) {
-        this.numPages = pdfInfo.numPages;
-        var loadingTask = this.loadingTask;
-        var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
-        this.pdfDocument = pdfDocument;
-        loadingTask._capability.resolve(pdfDocument);
-      }, this);
-      messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
-        this._passwordCapability = (0, _util.createPromiseCapability)();
-        if (loadingTask.onPassword) {
-          var updatePassword = password => {
-            this._passwordCapability.resolve({ password });
-          };
-          try {
-            loadingTask.onPassword(updatePassword, exception.code);
-          } catch (ex) {
-            this._passwordCapability.reject(ex);
-          }
-        } else {
-          this._passwordCapability.reject(new _util.PasswordException(exception.message, exception.code));
-        }
-        return this._passwordCapability.promise;
-      }, this);
-      messageHandler.on('PasswordException', function transportPasswordException(exception) {
-        loadingTask._capability.reject(new _util.PasswordException(exception.message, exception.code));
-      }, this);
-      messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
-        this.loadingTask._capability.reject(new _util.InvalidPDFException(exception.message));
-      }, this);
-      messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
-        this.loadingTask._capability.reject(new _util.MissingPDFException(exception.message));
-      }, this);
-      messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
-        this.loadingTask._capability.reject(new _util.UnexpectedResponseException(exception.message, exception.status));
-      }, this);
-      messageHandler.on('UnknownError', function transportUnknownError(exception) {
-        this.loadingTask._capability.reject(new _util.UnknownErrorException(exception.message, exception.details));
-      }, this);
-      messageHandler.on('DataLoaded', function transportPage(data) {
-        this.downloadInfoCapability.resolve(data);
-      }, this);
-      messageHandler.on('StartRenderPage', function transportRender(data) {
-        if (this.destroyed) {
-          return;
-        }
-        var page = this.pageCache[data.pageIndex];
-        page._stats.timeEnd('Page Request');
-        page._startRenderPage(data.transparency, data.intent);
-      }, this);
-      messageHandler.on('RenderPageChunk', function transportRender(data) {
-        if (this.destroyed) {
-          return;
-        }
-        var page = this.pageCache[data.pageIndex];
-        page._renderPageChunk(data.operatorList, data.intent);
-      }, this);
-      messageHandler.on('commonobj', function transportObj(data) {
-        if (this.destroyed) {
-          return;
-        }
-        var id = data[0];
-        var type = data[1];
-        if (this.commonObjs.hasData(id)) {
-          return;
-        }
-        switch (type) {
-          case 'Font':
-            var exportedData = data[2];
-            let params = this._params;
-            if ('error' in exportedData) {
-              var exportedError = exportedData.error;
-              (0, _util.warn)('Error during font loading: ' + exportedError);
-              this.commonObjs.resolve(id, exportedError);
-              break;
-            }
-            var fontRegistry = null;
-            if (params.pdfBug && _global_scope2.default.FontInspector && _global_scope2.default.FontInspector.enabled) {
-              fontRegistry = {
-                registerFont(font, url) {
-                  _global_scope2.default['FontInspector'].fontAdded(font, url);
-                }
-              };
-            }
-            var font = new _font_loader.FontFaceObject(exportedData, {
-              isEvalSupported: params.isEvalSupported,
-              disableFontFace: params.disableFontFace,
-              ignoreErrors: params.ignoreErrors,
-              onUnsupportedFeature: this._onUnsupportedFeature.bind(this),
-              fontRegistry
-            });
-            var fontReady = fontObjs => {
-              this.commonObjs.resolve(id, font);
-            };
-            this.fontLoader.bind([font], fontReady);
-            break;
-          case 'FontPath':
-            this.commonObjs.resolve(id, data[2]);
-            break;
-          default:
-            throw new Error(`Got unknown common object type ${type}`);
-        }
-      }, this);
-      messageHandler.on('obj', function transportObj(data) {
-        if (this.destroyed) {
-          return;
-        }
-        var id = data[0];
-        var pageIndex = data[1];
-        var type = data[2];
-        var pageProxy = this.pageCache[pageIndex];
-        var imageData;
-        if (pageProxy.objs.hasData(id)) {
-          return;
-        }
-        switch (type) {
-          case 'JpegStream':
-            imageData = data[3];
-            return new Promise((resolve, reject) => {
-              const img = new Image();
-              img.onload = function () {
-                resolve(img);
-              };
-              img.onerror = function () {
-                reject(new Error('Error during JPEG image loading'));
-              };
-              img.src = imageData;
-            }).then(img => {
-              pageProxy.objs.resolve(id, img);
-            });
-          case 'Image':
-            imageData = data[3];
-            pageProxy.objs.resolve(id, imageData);
-            var MAX_IMAGE_SIZE_TO_STORE = 8000000;
-            if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
-              pageProxy.cleanupAfterRender = true;
-            }
-            break;
-          default:
-            throw new Error(`Got unknown object type ${type}`);
-        }
-      }, this);
-      messageHandler.on('DocProgress', function transportDocProgress(data) {
-        if (this.destroyed) {
-          return;
-        }
-        var loadingTask = this.loadingTask;
-        if (loadingTask.onProgress) {
-          loadingTask.onProgress({
-            loaded: data.loaded,
-            total: data.total
-          });
-        }
-      }, this);
-      messageHandler.on('PageError', function transportError(data) {
-        if (this.destroyed) {
-          return;
-        }
-        var page = this.pageCache[data.pageNum - 1];
-        var intentState = page.intentStates[data.intent];
-        if (intentState.displayReadyCapability) {
-          intentState.displayReadyCapability.reject(data.error);
-        } else {
-          throw new Error(data.error);
-        }
-        if (intentState.operatorList) {
-          intentState.operatorList.lastChunk = true;
-          for (var i = 0; i < intentState.renderTasks.length; i++) {
-            intentState.renderTasks[i].operatorListChanged();
-          }
-        }
-      }, this);
-      messageHandler.on('UnsupportedFeature', this._onUnsupportedFeature, this);
-      messageHandler.on('JpegDecode', function (data) {
-        if (this.destroyed) {
-          return Promise.reject(new Error('Worker was destroyed'));
-        }
-        if (typeof document === 'undefined') {
-          return Promise.reject(new Error('"document" is not defined.'));
-        }
-        var imageUrl = data[0];
-        var components = data[1];
-        if (components !== 3 && components !== 1) {
-          return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
-        }
-        return new Promise(function (resolve, reject) {
-          var img = new Image();
-          img.onload = function () {
-            var width = img.width;
-            var height = img.height;
-            var size = width * height;
-            var rgbaLength = size * 4;
-            var buf = new Uint8ClampedArray(size * components);
-            var tmpCanvas = document.createElement('canvas');
-            tmpCanvas.width = width;
-            tmpCanvas.height = height;
-            var tmpCtx = tmpCanvas.getContext('2d');
-            tmpCtx.drawImage(img, 0, 0);
-            var data = tmpCtx.getImageData(0, 0, width, height).data;
-            var i, j;
-            if (components === 3) {
-              for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
-                buf[j] = data[i];
-                buf[j + 1] = data[i + 1];
-                buf[j + 2] = data[i + 2];
-              }
-            } else if (components === 1) {
-              for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
-                buf[j] = data[i];
-              }
-            }
-            resolve({
-              data: buf,
-              width,
-              height
-            });
-          };
-          img.onerror = function () {
-            reject(new Error('JpegDecode failed to load image'));
-          };
-          img.src = imageUrl;
-        });
-      }, this);
-      messageHandler.on('FetchBuiltInCMap', function (data) {
-        if (this.destroyed) {
-          return Promise.reject(new Error('Worker was destroyed'));
-        }
-        return this.CMapReaderFactory.fetch({ name: data.name });
-      }, this);
-    },
-    _onUnsupportedFeature({ featureId }) {
+        img.src = imageUrl;
+      });
+    }, this);
+    messageHandler.on('FetchBuiltInCMap', function (data) {
+      if (this.destroyed) {
+        return Promise.reject(new Error('Worker was destroyed'));
+      }
+      return this.CMapReaderFactory.fetch({ name: data.name });
+    }, this);
+  }
+  _onUnsupportedFeature({ featureId }) {
+    if (this.destroyed) {
+      return;
+    }
+    if (this.loadingTask.onUnsupportedFeature) {
+      this.loadingTask.onUnsupportedFeature(featureId);
+    }
+  }
+  getData() {
+    return this.messageHandler.sendWithPromise('GetData', null);
+  }
+  getPage(pageNumber) {
+    if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
+      return Promise.reject(new Error('Invalid page request'));
+    }
+    const pageIndex = pageNumber - 1;
+    if (pageIndex in this.pagePromises) {
+      return this.pagePromises[pageIndex];
+    }
+    const promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex }).then(pageInfo => {
       if (this.destroyed) {
-        return;
-      }
-      let loadingTask = this.loadingTask;
-      if (loadingTask.onUnsupportedFeature) {
-        loadingTask.onUnsupportedFeature(featureId);
-      }
-    },
-    getData: function WorkerTransport_getData() {
-      return this.messageHandler.sendWithPromise('GetData', null);
-    },
-    getPage(pageNumber) {
-      if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
-        return Promise.reject(new Error('Invalid page request'));
-      }
-      var pageIndex = pageNumber - 1;
-      if (pageIndex in this.pagePromises) {
-        return this.pagePromises[pageIndex];
-      }
-      var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex }).then(pageInfo => {
-        if (this.destroyed) {
-          throw new Error('Transport destroyed');
-        }
-        let page = new PDFPageProxy(pageIndex, pageInfo, this, this._params.pdfBug);
-        this.pageCache[pageIndex] = page;
-        return page;
-      });
-      this.pagePromises[pageIndex] = promise;
-      return promise;
-    },
-    getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
-      return this.messageHandler.sendWithPromise('GetPageIndex', { ref }).catch(function (reason) {
-        return Promise.reject(new Error(reason));
-      });
-    },
-    getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
-      return this.messageHandler.sendWithPromise('GetAnnotations', {
-        pageIndex,
-        intent
-      });
-    },
-    getDestinations: function WorkerTransport_getDestinations() {
-      return this.messageHandler.sendWithPromise('GetDestinations', null);
-    },
-    getDestination: function WorkerTransport_getDestination(id) {
-      if (typeof id !== 'string') {
-        return Promise.reject(new Error('Invalid destination request.'));
-      }
-      return this.messageHandler.sendWithPromise('GetDestination', { id });
-    },
-    getPageLabels: function WorkerTransport_getPageLabels() {
-      return this.messageHandler.sendWithPromise('GetPageLabels', null);
-    },
-    getPageMode() {
-      return this.messageHandler.sendWithPromise('GetPageMode', null);
-    },
-    getAttachments: function WorkerTransport_getAttachments() {
-      return this.messageHandler.sendWithPromise('GetAttachments', null);
-    },
-    getJavaScript: function WorkerTransport_getJavaScript() {
-      return this.messageHandler.sendWithPromise('GetJavaScript', null);
-    },
-    getOutline: function WorkerTransport_getOutline() {
-      return this.messageHandler.sendWithPromise('GetOutline', null);
-    },
-    getMetadata: function WorkerTransport_getMetadata() {
-      return this.messageHandler.sendWithPromise('GetMetadata', null).then(results => {
-        return {
-          info: results[0],
-          metadata: results[1] ? new _metadata.Metadata(results[1]) : null,
-          contentDispositionFilename: this._fullReader ? this._fullReader.filename : null
-        };
-      });
-    },
-    getStats: function WorkerTransport_getStats() {
-      return this.messageHandler.sendWithPromise('GetStats', null);
-    },
-    startCleanup: function WorkerTransport_startCleanup() {
-      this.messageHandler.sendWithPromise('Cleanup', null).then(() => {
-        for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
-          var page = this.pageCache[i];
-          if (page) {
-            page.cleanup();
-          }
-        }
-        this.commonObjs.clear();
-        this.fontLoader.clear();
-      });
-    },
-    get loadingParams() {
-      let params = this._params;
-      return (0, _util.shadow)(this, 'loadingParams', {
-        disableAutoFetch: params.disableAutoFetch,
-        disableCreateObjectURL: params.disableCreateObjectURL,
-        disableFontFace: params.disableFontFace,
-        nativeImageDecoderSupport: params.nativeImageDecoderSupport
-      });
-    }
-  };
-  return WorkerTransport;
-}();
+        throw new Error('Transport destroyed');
+      }
+      const page = new PDFPageProxy(pageIndex, pageInfo, this, this._params.pdfBug);
+      this.pageCache[pageIndex] = page;
+      return page;
+    });
+    this.pagePromises[pageIndex] = promise;
+    return promise;
+  }
+  getPageIndex(ref) {
+    return this.messageHandler.sendWithPromise('GetPageIndex', { ref }).catch(function (reason) {
+      return Promise.reject(new Error(reason));
+    });
+  }
+  getAnnotations(pageIndex, intent) {
+    return this.messageHandler.sendWithPromise('GetAnnotations', {
+      pageIndex,
+      intent
+    });
+  }
+  getDestinations() {
+    return this.messageHandler.sendWithPromise('GetDestinations', null);
+  }
+  getDestination(id) {
+    if (typeof id !== 'string') {
+      return Promise.reject(new Error('Invalid destination request.'));
+    }
+    return this.messageHandler.sendWithPromise('GetDestination', { id });
+  }
+  getPageLabels() {
+    return this.messageHandler.sendWithPromise('GetPageLabels', null);
+  }
+  getPageMode() {
+    return this.messageHandler.sendWithPromise('GetPageMode', null);
+  }
+  getAttachments() {
+    return this.messageHandler.sendWithPromise('GetAttachments', null);
+  }
+  getJavaScript() {
+    return this.messageHandler.sendWithPromise('GetJavaScript', null);
+  }
+  getOutline() {
+    return this.messageHandler.sendWithPromise('GetOutline', null);
+  }
+  getPermissions() {
+    return this.messageHandler.sendWithPromise('GetPermissions', null);
+  }
+  getMetadata() {
+    return this.messageHandler.sendWithPromise('GetMetadata', null).then(results => {
+      return {
+        info: results[0],
+        metadata: results[1] ? new _metadata.Metadata(results[1]) : null,
+        contentDispositionFilename: this._fullReader ? this._fullReader.filename : null
+      };
+    });
+  }
+  getStats() {
+    return this.messageHandler.sendWithPromise('GetStats', null);
+  }
+  startCleanup() {
+    this.messageHandler.sendWithPromise('Cleanup', null).then(() => {
+      for (let i = 0, ii = this.pageCache.length; i < ii; i++) {
+        const page = this.pageCache[i];
+        if (page) {
+          page.cleanup();
+        }
+      }
+      this.commonObjs.clear();
+      this.fontLoader.clear();
+    });
+  }
+  get loadingParams() {
+    const params = this._params;
+    return (0, _util.shadow)(this, 'loadingParams', {
+      disableAutoFetch: params.disableAutoFetch,
+      disableCreateObjectURL: params.disableCreateObjectURL,
+      disableFontFace: params.disableFontFace,
+      nativeImageDecoderSupport: params.nativeImageDecoderSupport
+    });
+  }
+}
 var PDFObjects = function PDFObjectsClosure() {
   function PDFObjects() {
     this.objs = Object.create(null);
   }
   PDFObjects.prototype = {
     ensureObj: function PDFObjects_ensureObj(objId) {
       if (this.objs[objId]) {
         return this.objs[objId];
@@ -5553,18 +5548,18 @@ var InternalRenderTask = function Intern
         }
       });
     }
   };
   return InternalRenderTask;
 }();
 var version, build;
 {
-  exports.version = version = '2.0.775';
-  exports.build = build = '20cd1b35';
+  exports.version = version = '2.0.815';
+  exports.build = build = 'd6927376';
 }
 exports.getDocument = getDocument;
 exports.LoopbackPort = LoopbackPort;
 exports.PDFDataRangeTransport = PDFDataRangeTransport;
 exports.PDFWorker = PDFWorker;
 exports.PDFDocumentProxy = PDFDocumentProxy;
 exports.PDFPageProxy = PDFPageProxy;
 exports.setPDFNetworkStreamFactory = setPDFNetworkStreamFactory;
--- a/browser/extensions/pdfjs/content/build/pdf.worker.js
+++ b/browser/extensions/pdfjs/content/build/pdf.worker.js
@@ -1,13 +1,13 @@
 /**
  * @licstart The following is the entire license notice for the
  * Javascript code in this page
  *
- * Copyright 2017 Mozilla Foundation
+ * Copyright 2018 Mozilla Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
@@ -118,18 +118,18 @@ return /******/ (function(modules) { // 
 /************************************************************************/
 /******/ ([
 /* 0 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-var pdfjsVersion = '2.0.775';
-var pdfjsBuild = '20cd1b35';
+var pdfjsVersion = '2.0.815';
+var pdfjsBuild = 'd6927376';
 var pdfjsCoreWorker = __w_pdfjs_require__(1);
 exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
 
 /***/ }),
 /* 1 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
@@ -322,17 +322,17 @@ var WorkerMessageHandler = {
     });
   },
   createDocumentHandler(docParams, port) {
     var pdfManager;
     var terminated = false;
     var cancelXHRs = null;
     var WorkerTasks = [];
     let apiVersion = docParams.apiVersion;
-    let workerVersion = '2.0.775';
+    let workerVersion = '2.0.815';
     if (apiVersion !== workerVersion) {
       throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
     }
     var docId = docParams.docId;
     var docBaseUrl = docParams.docBaseUrl;
     var workerHandlerName = docParams.docId + '_worker';
     var handler = new _message_handler.MessageHandler(workerHandlerName, docId, port);
     handler.postMessageTransfers = docParams.postMessageTransfers;
@@ -564,16 +564,19 @@ var WorkerMessageHandler = {
       return pdfManager.ensureCatalog('attachments');
     });
     handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
       return pdfManager.ensureCatalog('javaScript');
     });
     handler.on('GetOutline', function wphSetupGetOutline(data) {
       return pdfManager.ensureCatalog('documentOutline');
     });
+    handler.on('GetPermissions', function (data) {
+      return pdfManager.ensureCatalog('permissions');
+    });
     handler.on('GetMetadata', function wphSetupGetMetadata(data) {
       return Promise.all([pdfManager.ensureDoc('documentInfo'), pdfManager.ensureCatalog('metadata')]);
     });
     handler.on('GetData', function wphSetupGetData(data) {
       pdfManager.requestLoadedStream();
       return pdfManager.onLoadedStream().then(function (stream) {
         return stream.bytes;
       });
@@ -710,30 +713,40 @@ exports.WorkerMessageHandler = WorkerMes
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
-exports.unreachable = exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.URL = exports.ReadableStream = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isSpace = exports.isString = exports.isNum = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.info = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.getInheritableProperty = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.FormatError = exports.XRefParseException = exports.toRomanNumerals = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PasswordResponses = exports.PasswordException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined;
+exports.unreachable = exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.URL = exports.ReadableStream = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isSpace = exports.isString = exports.isNum = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.info = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.getInheritableProperty = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.FormatError = exports.XRefParseException = exports.toRomanNumerals = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined;
 
 __w_pdfjs_require__(3);
 
 var _streams_polyfill = __w_pdfjs_require__(5);
 
 var _url_polyfill = __w_pdfjs_require__(7);
 
 var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
 const NativeImageDecoding = {
   NONE: 'none',
   DECODE: 'decode',
   DISPLAY: 'display'
 };
+const PermissionFlag = {
+  PRINT: 0x04,
+  MODIFY_CONTENTS: 0x08,
+  COPY: 0x10,
+  MODIFY_ANNOTATIONS: 0x20,
+  FILL_INTERACTIVE_FORMS: 0x100,
+  COPY_FOR_ACCESSIBILITY: 0x200,
+  ASSEMBLE: 0x400,
+  PRINT_HIGH_QUALITY: 0x800
+};
 var TextRenderingMode = {
   FILL: 0,
   STROKE: 1,
   FILL_STROKE: 2,
   INVISIBLE: 3,
   FILL_ADD_TO_PATH: 4,
   STROKE_ADD_TO_PATH: 5,
   FILL_STROKE_ADD_TO_PATH: 6,
@@ -1446,16 +1459,17 @@ exports.ImageKind = ImageKind;
 exports.CMapCompressionType = CMapCompressionType;
 exports.AbortException = AbortException;
 exports.InvalidPDFException = InvalidPDFException;
 exports.MissingDataException = MissingDataException;
 exports.MissingPDFException = MissingPDFException;
 exports.NativeImageDecoding = NativeImageDecoding;
 exports.PasswordException = PasswordException;
 exports.PasswordResponses = PasswordResponses;
+exports.PermissionFlag = PermissionFlag;
 exports.StreamType = StreamType;
 exports.TextRenderingMode = TextRenderingMode;
 exports.UnexpectedResponseException = UnexpectedResponseException;
 exports.UnknownErrorException = UnknownErrorException;
 exports.Util = Util;
 exports.toRomanNumerals = toRomanNumerals;
 exports.XRefParseException = XRefParseException;
 exports.FormatError = FormatError;
@@ -5740,654 +5754,674 @@ var _chunked_stream = __w_pdfjs_require_
 
 var _crypto = __w_pdfjs_require__(24);
 
 var _colorspace = __w_pdfjs_require__(25);
 
 function fetchDestination(dest) {
   return (0, _primitives.isDict)(dest) ? dest.get('D') : dest;
 }
-var Catalog = function CatalogClosure() {
-  function Catalog(pdfManager, xref) {
+class Catalog {
+  constructor(pdfManager, xref) {
     this.pdfManager = pdfManager;
     this.xref = xref;
     this.catDict = xref.getCatalogObj();
     if (!(0, _primitives.isDict)(this.catDict)) {
-      throw new _util.FormatError('catalog object is not a dictionary');
+      throw new _util.FormatError('Catalog object is not a dictionary.');
     }
     this.fontCache = new _primitives.RefSetCache();
     this.builtInCMapCache = new Map();
     this.pageKidsCountCache = new _primitives.RefSetCache();
   }
-  Catalog.prototype = {
-    get metadata() {
-      var streamRef = this.catDict.getRaw('Metadata');
-      if (!(0, _primitives.isRef)(streamRef)) {
-        return (0, _util.shadow)(this, 'metadata', null);
-      }
-      var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
-      var stream = this.xref.fetch(streamRef, !encryptMetadata);
-      var metadata;
-      if (stream && (0, _primitives.isDict)(stream.dict)) {
-        var type = stream.dict.get('Type');
-        var subtype = stream.dict.get('Subtype');
-        if ((0, _primitives.isName)(type, 'Metadata') && (0, _primitives.isName)(subtype, 'XML')) {
-          try {
-            metadata = (0, _util.stringToUTF8String)((0, _util.bytesToString)(stream.getBytes()));
-          } catch (e) {
-            if (e instanceof _util.MissingDataException) {
-              throw e;
-            }
-            (0, _util.info)('Skipping invalid metadata.');
-          }
-        }
-      }
-      return (0, _util.shadow)(this, 'metadata', metadata);
-    },
-    get toplevelPagesDict() {
-      var pagesObj = this.catDict.get('Pages');
-      if (!(0, _primitives.isDict)(pagesObj)) {
-        throw new _util.FormatError('invalid top-level pages dictionary');
-      }
-      return (0, _util.shadow)(this, 'toplevelPagesDict', pagesObj);
-    },
-    get documentOutline() {
-      var obj = null;
-      try {
-        obj = this.readDocumentOutline();
-      } catch (ex) {
-        if (ex instanceof _util.MissingDataException) {
-          throw ex;
-        }
-        (0, _util.warn)('Unable to read document outline');
-      }
-      return (0, _util.shadow)(this, 'documentOutline', obj);
-    },
-    readDocumentOutline: function Catalog_readDocumentOutline() {
-      var obj = this.catDict.get('Outlines');
-      if (!(0, _primitives.isDict)(obj)) {
-        return null;
-      }
-      obj = obj.getRaw('First');
-      if (!(0, _primitives.isRef)(obj)) {
-        return null;
-      }
-      var root = { items: [] };
-      var queue = [{
-        obj,
-        parent: root
-      }];
-      var processed = new _primitives.RefSet();
-      processed.put(obj);
-      var xref = this.xref,
+  get metadata() {
+    const streamRef = this.catDict.getRaw('Metadata');
+    if (!(0, _primitives.isRef)(streamRef)) {
+      return (0, _util.shadow)(this, 'metadata', null);
+    }
+    const suppressEncryption = !(this.xref.encrypt && this.xref.encrypt.encryptMetadata);
+    const stream = this.xref.fetch(streamRef, suppressEncryption);
+    let metadata;
+    if (stream && (0, _primitives.isDict)(stream.dict)) {
+      const type = stream.dict.get('Type');
+      const subtype = stream.dict.get('Subtype');
+      if ((0, _primitives.isName)(type, 'Metadata') && (0, _primitives.isName)(subtype, 'XML')) {
+        try {
+          metadata = (0, _util.stringToUTF8String)((0, _util.bytesToString)(stream.getBytes()));
+        } catch (e) {
+          if (e instanceof _util.MissingDataException) {
+            throw e;
+          }
+          (0, _util.info)('Skipping invalid metadata.');
+        }
+      }
+    }
+    return (0, _util.shadow)(this, 'metadata', metadata);
+  }
+  get toplevelPagesDict() {
+    const pagesObj = this.catDict.get('Pages');
+    if (!(0, _primitives.isDict)(pagesObj)) {
+      throw new _util.FormatError('Invalid top-level pages dictionary.');
+    }
+    return (0, _util.shadow)(this, 'toplevelPagesDict', pagesObj);
+  }
+  get documentOutline() {
+    let obj = null;
+    try {
+      obj = this._readDocumentOutline();
+    } catch (ex) {
+      if (ex instanceof _util.MissingDataException) {
+        throw ex;
+      }
+      (0, _util.warn)('Unable to read document outline.');
+    }
+    return (0, _util.shadow)(this, 'documentOutline', obj);
+  }
+  _readDocumentOutline() {
+    let obj = this.catDict.get('Outlines');
+    if (!(0, _primitives.isDict)(obj)) {
+      return null;
+    }
+    obj = obj.getRaw('First');
+    if (!(0, _primitives.isRef)(obj)) {
+      return null;
+    }
+    const root = { items: [] };
+    const queue = [{
+      obj,
+      parent: root
+    }];
+    const processed = new _primitives.RefSet();
+    processed.put(obj);
+    const xref = this.xref,
           blackColor = new Uint8ClampedArray(3);
-      while (queue.length > 0) {
-        var i = queue.shift();
-        var outlineDict = xref.fetchIfRef(i.obj);
-        if (outlineDict === null) {
-          continue;
-        }
-        if (!outlineDict.has('Title')) {
-          throw new _util.FormatError('Invalid outline item');
-        }
-        var data = {
-          url: null,
-          dest: null
-        };
-        Catalog.parseDestDictionary({
-          destDict: outlineDict,
-          resultObj: data,
-          docBaseUrl: this.pdfManager.docBaseUrl
-        });
-        var title = outlineDict.get('Title');
-        var flags = outlineDict.get('F') || 0;
-        var color = outlineDict.getArray('C'),
-            rgbColor = blackColor;
-        if (Array.isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
-          rgbColor = _colorspace.ColorSpace.singletons.rgb.getRgb(color, 0);
-        }
-        var outlineItem = {
-          dest: data.dest,
-          url: data.url,
-          unsafeUrl: data.unsafeUrl,
-          newWindow: data.newWindow,
-          title: (0, _util.stringToPDFString)(title),
-          color: rgbColor,
-          count: outlineDict.get('Count'),
-          bold: !!(flags & 2),
-          italic: !!(flags & 1),
-          items: []
-        };
-        i.parent.items.push(outlineItem);
-        obj = outlineDict.getRaw('First');
-        if ((0, _primitives.isRef)(obj) && !processed.has(obj)) {
-          queue.push({
-            obj,
-            parent: outlineItem
-          });
-          processed.put(obj);
-        }
-        obj = outlineDict.getRaw('Next');
-        if ((0, _primitives.isRef)(obj) && !processed.has(obj)) {
-          queue.push({
-            obj,
-            parent: i.parent
-          });
-          processed.put(obj);
-        }
-      }
-      return root.items.length > 0 ? root.items : null;
-    },
-    get numPages() {
-      var obj = this.toplevelPagesDict.get('Count');
-      if (!Number.isInteger(obj)) {
-        throw new _util.FormatError('page count in top level pages object is not an integer');
-      }
-      return (0, _util.shadow)(this, 'numPages', obj);
-    },
-    get destinations() {
-      const obj = this._readDests(),
-            dests = Object.create(null);
-      if (obj instanceof NameTree) {
-        const names = obj.getAll();
-        for (let name in names) {
-          dests[name] = fetchDestination(names[name]);
-        }
-      } else if (obj instanceof _primitives.Dict) {
-        obj.forEach(function (key, value) {
-          if (value) {
-            dests[key] = fetchDestination(value);
-          }
-        });
-      }
-      return (0, _util.shadow)(this, 'destinations', dests);
-    },
-    getDestination(destinationId) {
-      const obj = this._readDests();
-      if (obj instanceof NameTree || obj instanceof _primitives.Dict) {
-        return fetchDestination(obj.get(destinationId) || null);
-      }
+    while (queue.length > 0) {
+      const i = queue.shift();
+      const outlineDict = xref.fetchIfRef(i.obj);
+      if (outlineDict === null) {
+        continue;
+      }
+      if (!outlineDict.has('Title')) {
+        throw new _util.FormatError('Invalid outline item encountered.');
+      }
+      const data = {
+        url: null,
+        dest: null
+      };
+      Catalog.parseDestDictionary({
+        destDict: outlineDict,
+        resultObj: data,
+        docBaseUrl: this.pdfManager.docBaseUrl
+      });
+      const title = outlineDict.get('Title');
+      const flags = outlineDict.get('F') || 0;
+      const color = outlineDict.getArray('C');
+      let rgbColor = blackColor;
+      if (Array.isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
+        rgbColor = _colorspace.ColorSpace.singletons.rgb.getRgb(color, 0);
+      }
+      const outlineItem = {
+        dest: data.dest,
+        url: data.url,
+        unsafeUrl: data.unsafeUrl,
+        newWindow: data.newWindow,
+        title: (0, _util.stringToPDFString)(title),
+        color: rgbColor,
+        count: outlineDict.get('Count'),
+        bold: !!(flags & 2),
+        italic: !!(flags & 1),
+        items: []
+      };
+      i.parent.items.push(outlineItem);
+      obj = outlineDict.getRaw('First');
+      if ((0, _primitives.isRef)(obj) && !processed.has(obj)) {
+        queue.push({
+          obj,
+          parent: outlineItem
+        });
+        processed.put(obj);
+      }
+      obj = outlineDict.getRaw('Next');
+      if ((0, _primitives.isRef)(obj) && !processed.has(obj)) {
+        queue.push({
+          obj,
+          parent: i.parent
+        });
+        processed.put(obj);
+      }
+    }
+    return root.items.length > 0 ? root.items : null;
+  }
+  get permissions() {
+    let permissions = null;
+    try {
+      permissions = this._readPermissions();
+    } catch (ex) {
+      if (ex instanceof _util.MissingDataException) {
+        throw ex;
+      }
+      (0, _util.warn)('Unable to read permissions.');
+    }
+    return (0, _util.shadow)(this, 'permissions', permissions);
+  }
+  _readPermissions() {
+    const encrypt = this.xref.trailer.get('Encrypt');
+    if (!(0, _primitives.isDict)(encrypt)) {
+      return null;
+    }
+    let flags = encrypt.get('P');
+    if (!(0, _util.isNum)(flags)) {
       return null;
-    },
-    _readDests() {
-      const obj = this.catDict.get('Names');
-      if (obj && obj.has('Dests')) {
-        return new NameTree(obj.getRaw('Dests'), this.xref);
-      } else if (this.catDict.has('Dests')) {
-        return this.catDict.get('Dests');
-      }
-    },
-    get pageLabels() {
-      var obj = null;
-      try {
-        obj = this.readPageLabels();
-      } catch (ex) {
-        if (ex instanceof _util.MissingDataException) {
-          throw ex;
-        }
-        (0, _util.warn)('Unable to read page labels.');
-      }
-      return (0, _util.shadow)(this, 'pageLabels', obj);
-    },
-    readPageLabels: function Catalog_readPageLabels() {
-      var obj = this.catDict.getRaw('PageLabels');
-      if (!obj) {
-        return null;
-      }
-      var pageLabels = new Array(this.numPages);
-      var style = null;
-      var prefix = '';
-      var numberTree = new NumberTree(obj, this.xref);
-      var nums = numberTree.getAll();
-      var currentLabel = '',
+    }
+    flags += 2 ** 32;
+    const permissions = [];
+    for (const key in _util.PermissionFlag) {
+      const value = _util.PermissionFlag[key];
+      if (flags & value) {
+        permissions.push(value);
+      }
+    }
+    return permissions;
+  }
+  get numPages() {
+    const obj = this.toplevelPagesDict.get('Count');
+    if (!Number.isInteger(obj)) {
+      throw new _util.FormatError('Page count in top-level pages dictionary is not an integer.');
+    }
+    return (0, _util.shadow)(this, 'numPages', obj);
+  }
+  get destinations() {
+    const obj = this._readDests(),
+          dests = Object.create(null);
+    if (obj instanceof NameTree) {
+      const names = obj.getAll();
+      for (let name in names) {
+        dests[name] = fetchDestination(names[name]);
+      }
+    } else if (obj instanceof _primitives.Dict) {
+      obj.forEach(function (key, value) {
+        if (value) {
+          dests[key] = fetchDestination(value);
+        }
+      });
+    }
+    return (0, _util.shadow)(this, 'destinations', dests);
+  }
+  getDestination(destinationId) {
+    const obj = this._readDests();
+    if (obj instanceof NameTree || obj instanceof _primitives.Dict) {
+      return fetchDestination(obj.get(destinationId) || null);
+    }
+    return null;
+  }
+  _readDests() {
+    const obj = this.catDict.get('Names');
+    if (obj && obj.has('Dests')) {
+      return new NameTree(obj.getRaw('Dests'), this.xref);
+    } else if (this.catDict.has('Dests')) {
+      return this.catDict.get('Dests');
+    }
+  }
+  get pageLabels() {
+    let obj = null;
+    try {
+      obj = this._readPageLabels();
+    } catch (ex) {
+      if (ex instanceof _util.MissingDataException) {
+        throw ex;
+      }
+      (0, _util.warn)('Unable to read page labels.');
+    }
+    return (0, _util.shadow)(this, 'pageLabels', obj);
+  }
+  _readPageLabels() {
+    const obj = this.catDict.getRaw('PageLabels');
+    if (!obj) {
+      return null;
+    }
+    const pageLabels = new Array(this.numPages);
+    let style = null,
+        prefix = '';
+    const numberTree = new NumberTree(obj, this.xref);
+    const nums = numberTree.getAll();
+    let currentLabel = '',
+        currentIndex = 1;
+    for (let i = 0, ii = this.numPages; i < ii; i++) {
+      if (i in nums) {
+        const labelDict = nums[i];
+        if (!(0, _primitives.isDict)(labelDict)) {
+          throw new _util.FormatError('PageLabel is not a dictionary.');
+        }
+        if (labelDict.has('Type') && !(0, _primitives.isName)(labelDict.get('Type'), 'PageLabel')) {
+          throw new _util.FormatError('Invalid type in PageLabel dictionary.');
+        }
+        if (labelDict.has('S')) {
+          const s = labelDict.get('S');
+          if (!(0, _primitives.isName)(s)) {
+            throw new _util.FormatError('Invalid style in PageLabel dictionary.');
+          }
+          style = s.name;
+        } else {
+          style = null;
+        }
+        if (labelDict.has('P')) {
+          const p = labelDict.get('P');
+          if (!(0, _util.isString)(p)) {
+            throw new _util.FormatError('Invalid prefix in PageLabel dictionary.');
+          }
+          prefix = (0, _util.stringToPDFString)(p);
+        } else {
+          prefix = '';
+        }
+        if (labelDict.has('St')) {
+          const st = labelDict.get('St');
+          if (!(Number.isInteger(st) && st >= 1)) {
+            throw new _util.FormatError('Invalid start in PageLabel dictionary.');
+          }
+          currentIndex = st;
+        } else {
           currentIndex = 1;
-      for (var i = 0, ii = this.numPages; i < ii; i++) {
-        if (i in nums) {
-          const labelDict = nums[i];
-          if (!(0, _primitives.isDict)(labelDict)) {
-            throw new _util.FormatError('The PageLabel is not a dictionary.');
-          }
-          if (labelDict.has('Type') && !(0, _primitives.isName)(labelDict.get('Type'), 'PageLabel')) {
-            throw new _util.FormatError('Invalid type in PageLabel dictionary.');
-          }
-          if (labelDict.has('S')) {
-            const s = labelDict.get('S');
-            if (!(0, _primitives.isName)(s)) {
-              throw new _util.FormatError('Invalid style in PageLabel dictionary.');
-            }
-            style = s.name;
-          } else {
-            style = null;
-          }
-          if (labelDict.has('P')) {
-            const p = labelDict.get('P');
-            if (!(0, _util.isString)(p)) {
-              throw new _util.FormatError('Invalid prefix in PageLabel dictionary.');
-            }
-            prefix = (0, _util.stringToPDFString)(p);
-          } else {
-            prefix = '';
-          }
-          if (labelDict.has('St')) {
-            const st = labelDict.get('St');
-            if (!(Number.isInteger(st) && st >= 1)) {
-              throw new _util.FormatError('Invalid start in PageLabel dictionary.');
-            }
-            currentIndex = st;
-          } else {
-            currentIndex = 1;
-          }
-        }
-        switch (style) {
-          case 'D':
-            currentLabel = currentIndex;
-            break;
-          case 'R':
-          case 'r':
-            currentLabel = (0, _util.toRomanNumerals)(currentIndex, style === 'r');
-            break;
-          case 'A':
-          case 'a':
-            var LIMIT = 26;
-            var A_UPPER_CASE = 0x41,
+        }
+      }
+      switch (style) {
+        case 'D':
+          currentLabel = currentIndex;
+          break;
+        case 'R':
+        case 'r':
+          currentLabel = (0, _util.toRomanNumerals)(currentIndex, style === 'r');
+          break;
+        case 'A':
+        case 'a':
+          const LIMIT = 26;
+          const A_UPPER_CASE = 0x41,
                 A_LOWER_CASE = 0x61;
-            var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
-            var letterIndex = currentIndex - 1;
-            var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
-            var charBuf = [];
-            for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
-              charBuf.push(character);
-            }
-            currentLabel = charBuf.join('');
-            break;
-          default:
-            if (style) {
-              throw new _util.FormatError(`Invalid style "${style}" in PageLabel dictionary.`);
-            }
-            currentLabel = '';
-        }
-        pageLabels[i] = prefix + currentLabel;
-        currentIndex++;
-      }
-      return pageLabels;
-    },
-    get pageMode() {
-      let obj = this.catDict.get('PageMode');
-      let pageMode = 'UseNone';
-      if ((0, _primitives.isName)(obj)) {
-        switch (obj.name) {
-          case 'UseNone':
-          case 'UseOutlines':
-          case 'UseThumbs':
-          case 'FullScreen':
-          case 'UseOC':
-          case 'UseAttachments':
-            pageMode = obj.name;
-        }
-      }
-      return (0, _util.shadow)(this, 'pageMode', pageMode);
-    },
-    get attachments() {
-      var xref = this.xref;
-      var attachments = null,
-          nameTreeRef;
-      var obj = this.catDict.get('Names');
-      if (obj) {
-        nameTreeRef = obj.getRaw('EmbeddedFiles');
-      }
-      if (nameTreeRef) {
-        var nameTree = new NameTree(nameTreeRef, xref);
-        var names = nameTree.getAll();
-        for (var name in names) {
-          var fs = new FileSpec(names[name], xref);
-          if (!attachments) {
-            attachments = Object.create(null);
-          }
-          attachments[(0, _util.stringToPDFString)(name)] = fs.serializable;
-        }
-      }
-      return (0, _util.shadow)(this, 'attachments', attachments);
-    },
-    get javaScript() {
-      var xref = this.xref;
-      var obj = this.catDict.get('Names');
-      let javaScript = null;
-      function appendIfJavaScriptDict(jsDict) {
-        var type = jsDict.get('S');
-        if (!(0, _primitives.isName)(type, 'JavaScript')) {
-          return;
-        }
-        var js = jsDict.get('JS');
-        if ((0, _primitives.isStream)(js)) {
-          js = (0, _util.bytesToString)(js.getBytes());
-        } else if (!(0, _util.isString)(js)) {
-          return;
-        }
-        if (!javaScript) {
-          javaScript = [];
-        }
-        javaScript.push((0, _util.stringToPDFString)(js));
-      }
-      if (obj && obj.has('JavaScript')) {
-        var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
-        var names = nameTree.getAll();
-        for (var name in names) {
-          var jsDict = names[name];
-          if ((0, _primitives.isDict)(jsDict)) {
-            appendIfJavaScriptDict(jsDict);
-          }
-        }
-      }
-      var openactionDict = this.catDict.get('OpenAction');
-      if ((0, _primitives.isDict)(openactionDict, 'Action')) {
-        var actionType = openactionDict.get('S');
-        if ((0, _primitives.isName)(actionType, 'Named')) {
-          var action = openactionDict.get('N');
-          if ((0, _primitives.isName)(action, 'Print')) {
-            if (!javaScript) {
-              javaScript = [];
-            }
-            javaScript.push('print({});');
-          }
-        } else {
-          appendIfJavaScriptDict(openactionDict);
-        }
-      }
-      return (0, _util.shadow)(this, 'javaScript', javaScript);
-    },
-    cleanup: function Catalog_cleanup() {
-      this.pageKidsCountCache.clear();
-      var promises = [];
-      this.fontCache.forEach(function (promise) {
-        promises.push(promise);
-      });
-      return Promise.all(promises).then(translatedFonts => {
-        for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
-          var font = translatedFonts[i].dict;
-          delete font.translated;
-        }
-        this.fontCache.clear();
-        this.builtInCMapCache.clear();
-      });
-    },
-    getPageDict: function Catalog_getPageDict(pageIndex) {
-      var capability = (0, _util.createPromiseCapability)();
-      var nodesToVisit = [this.catDict.getRaw('Pages')];
-      var count,
-          currentPageIndex = 0;
-      var xref = this.xref,
+          const baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
+          const letterIndex = currentIndex - 1;
+          const character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
+          const charBuf = [];
+          for (let j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
+            charBuf.push(character);
+          }
+          currentLabel = charBuf.join('');
+          break;
+        default:
+          if (style) {
+            throw new _util.FormatError(`Invalid style "${style}" in PageLabel dictionary.`);
+          }
+          currentLabel = '';
+      }
+      pageLabels[i] = prefix + currentLabel;
+      currentIndex++;
+    }
+    return pageLabels;
+  }
+  get pageMode() {
+    const obj = this.catDict.get('PageMode');
+    let pageMode = 'UseNone';
+    if ((0, _primitives.isName)(obj)) {
+      switch (obj.name) {
+        case 'UseNone':
+        case 'UseOutlines':
+        case 'UseThumbs':
+        case 'FullScreen':
+        case 'UseOC':
+        case 'UseAttachments':
+          pageMode = obj.name;
+      }
+    }
+    return (0, _util.shadow)(this, 'pageMode', pageMode);
+  }
+  get attachments() {
+    const obj = this.catDict.get('Names');
+    let attachments = null;
+    if (obj && obj.has('EmbeddedFiles')) {
+      const nameTree = new NameTree(obj.getRaw('EmbeddedFiles'), this.xref);
+      const names = nameTree.getAll();
+      for (const name in names) {
+        const fs = new FileSpec(names[name], this.xref);
+        if (!attachments) {
+          attachments = Object.create(null);
+        }
+        attachments[(0, _util.stringToPDFString)(name)] = fs.serializable;
+      }
+    }
+    return (0, _util.shadow)(this, 'attachments', attachments);
+  }
+  get javaScript() {
+    const obj = this.catDict.get('Names');
+    let javaScript = null;
+    function appendIfJavaScriptDict(jsDict) {
+      const type = jsDict.get('S');
+      if (!(0, _primitives.isName)(type, 'JavaScript')) {
+        return;
+      }
+      let js = jsDict.get('JS');
+      if ((0, _primitives.isStream)(js)) {
+        js = (0, _util.bytesToString)(js.getBytes());
+      } else if (!(0, _util.isString)(js)) {
+        return;
+      }
+      if (!javaScript) {
+        javaScript = [];
+      }
+      javaScript.push((0, _util.stringToPDFString)(js));
+    }
+    if (obj && obj.has('JavaScript')) {
+      const nameTree = new NameTree(obj.getRaw('JavaScript'), this.xref);
+      const names = nameTree.getAll();
+      for (const name in names) {
+        const jsDict = names[name];
+        if ((0, _primitives.isDict)(jsDict)) {
+          appendIfJavaScriptDict(jsDict);
+        }
+      }
+    }
+    const openActionDict = this.catDict.get('OpenAction');
+    if ((0, _primitives.isDict)(openActionDict, 'Action')) {
+      const actionType = openActionDict.get('S');
+      if ((0, _primitives.isName)(actionType, 'Named')) {
+        const action = openActionDict.get('N');
+        if ((0, _primitives.isName)(action, 'Print')) {
+          if (!javaScript) {
+            javaScript = [];
+          }
+          javaScript.push('print({});');
+        }
+      } else {
+        appendIfJavaScriptDict(openActionDict);
+      }
+    }
+    return (0, _util.shadow)(this, 'javaScript', javaScript);
+  }
+  cleanup() {
+    this.pageKidsCountCache.clear();
+    const promises = [];
+    this.fontCache.forEach(function (promise) {
+      promises.push(promise);
+    });
+    return Promise.all(promises).then(translatedFonts => {
+      for (let i = 0, ii = translatedFonts.length; i < ii; i++) {
+        const font = translatedFonts[i].dict;
+        delete font.translated;
+      }
+      this.fontCache.clear();
+      this.builtInCMapCache.clear();
+    });
+  }
+  getPageDict(pageIndex) {
+    const capability = (0, _util.createPromiseCapability)();
+    const nodesToVisit = [this.catDict.getRaw('Pages')];
+    const xref = this.xref,
           pageKidsCountCache = this.pageKidsCountCache;
-      function next() {
-        while (nodesToVisit.length) {
-          var currentNode = nodesToVisit.pop();
-          if ((0, _primitives.isRef)(currentNode)) {
-            count = pageKidsCountCache.get(currentNode);
-            if (count > 0 && currentPageIndex + count < pageIndex) {
-              currentPageIndex += count;
-              continue;
-            }
-            xref.fetchAsync(currentNode).then(function (obj) {
-              if ((0, _primitives.isDict)(obj, 'Page') || (0, _primitives.isDict)(obj) && !obj.has('Kids')) {
-                if (pageIndex === currentPageIndex) {
-                  if (currentNode && !pageKidsCountCache.has(currentNode)) {
-                    pageKidsCountCache.put(currentNode, 1);
-                  }
-                  capability.resolve([obj, currentNode]);
-                } else {
-                  currentPageIndex++;
-                  next();
-                }
-                return;
-              }
-              nodesToVisit.push(obj);
-              next();
-            }, capability.reject);
-            return;
-          }
-          if (!(0, _primitives.isDict)(currentNode)) {
-            capability.reject(new _util.FormatError('page dictionary kid reference points to wrong type of object'));
-            return;
-          }
-          count = currentNode.get('Count');
-          if (Number.isInteger(count) && count >= 0) {
-            var objId = currentNode.objId;
-            if (objId && !pageKidsCountCache.has(objId)) {
-              pageKidsCountCache.put(objId, count);
-            }
-            if (currentPageIndex + count <= pageIndex) {
-              currentPageIndex += count;
-              continue;
-            }
-          }
-          var kids = currentNode.get('Kids');
-          if (!Array.isArray(kids)) {
-            if ((0, _primitives.isName)(currentNode.get('Type'), 'Page') || !currentNode.has('Type') && currentNode.has('Contents')) {
-              if (currentPageIndex === pageIndex) {
-                capability.resolve([currentNode, null]);
-                return;
-              }
-              currentPageIndex++;
-              continue;
-            }
-            capability.reject(new _util.FormatError('page dictionary kids object is not an array'));
-            return;
-          }
-          for (var last = kids.length - 1; last >= 0; last--) {
-            nodesToVisit.push(kids[last]);
-          }
-        }
-        capability.reject(new Error('Page index ' + pageIndex + ' not found.'));
-      }
-      next();
-      return capability.promise;
-    },
-    getPageIndex: function Catalog_getPageIndex(pageRef) {
-      var xref = this.xref;
-      function pagesBeforeRef(kidRef) {
-        var total = 0;
-        var parentRef;
-        return xref.fetchAsync(kidRef).then(function (node) {
-          if ((0, _primitives.isRefsEqual)(kidRef, pageRef) && !(0, _primitives.isDict)(node, 'Page') && !((0, _primitives.isDict)(node) && !node.has('Type') && node.has('Contents'))) {
-            throw new _util.FormatError('The reference does not point to a /Page Dict.');
-          }
-          if (!node) {
-            return null;
-          }
-          if (!(0, _primitives.isDict)(node)) {
-            throw new _util.FormatError('node must be a Dict.');
-          }
-          parentRef = node.getRaw('Parent');
-          return node.getAsync('Parent');
-        }).then(function (parent) {
-          if (!parent) {
-            return null;
-          }
-          if (!(0, _primitives.isDict)(parent)) {
-            throw new _util.FormatError('parent must be a Dict.');
-          }
-          return parent.getAsync('Kids');
-        }).then(function (kids) {
-          if (!kids) {
-            return null;
-          }
-          var kidPromises = [];
-          var found = false;
-          for (var i = 0; i < kids.length; i++) {
-            var kid = kids[i];
-            if (!(0, _primitives.isRef)(kid)) {
-              throw new _util.FormatError('kid must be a Ref.');
-            }
-            if ((0, _primitives.isRefsEqual)(kid, kidRef)) {
-              found = true;
-              break;
-            }
-            kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
-              if (!(0, _primitives.isDict)(kid)) {
-                throw new _util.FormatError('kid node must be a Dict.');
-              }
-              if (kid.has('Count')) {
-                var count = kid.get('Count');
-                total += count;
+    let count,
+        currentPageIndex = 0;
+    function next() {
+      while (nodesToVisit.length) {
+        const currentNode = nodesToVisit.pop();
+        if ((0, _primitives.isRef)(currentNode)) {
+          count = pageKidsCountCache.get(currentNode);
+          if (count > 0 && currentPageIndex + count < pageIndex) {
+            currentPageIndex += count;
+            continue;
+          }
+          xref.fetchAsync(currentNode).then(function (obj) {
+            if ((0, _primitives.isDict)(obj, 'Page') || (0, _primitives.isDict)(obj) && !obj.has('Kids')) {
+              if (pageIndex === currentPageIndex) {
+                if (currentNode && !pageKidsCountCache.has(currentNode)) {
+                  pageKidsCountCache.put(currentNode, 1);
+                }
+                capability.resolve([obj, currentNode]);
               } else {
-                total++;
-              }
-            }));
-          }
-          if (!found) {
-            throw new _util.FormatError('kid ref not found in parents kids');
-          }
-          return Promise.all(kidPromises).then(function () {
-            return [total, parentRef];
-          });
-        });
-      }
-      var total = 0;
-      function next(ref) {
-        return pagesBeforeRef(ref).then(function (args) {
-          if (!args) {
-            return total;
-          }
-          var count = args[0];
-          var parentRef = args[1];
-          total += count;
-          return next(parentRef);
-        });
-      }
-      return next(pageRef);
-    }
-  };
-  Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
+                currentPageIndex++;
+                next();
+              }
+              return;
+            }
+            nodesToVisit.push(obj);
+            next();
+          }, capability.reject);
+          return;
+        }
+        if (!(0, _primitives.isDict)(currentNode)) {
+          capability.reject(new _util.FormatError('Page dictionary kid reference points to wrong type of object.'));
+          return;
+        }
+        count = currentNode.get('Count');
+        if (Number.isInteger(count) && count >= 0) {
+          const objId = currentNode.objId;
+          if (objId && !pageKidsCountCache.has(objId)) {
+            pageKidsCountCache.put(objId, count);
+          }
+          if (currentPageIndex + count <= pageIndex) {
+            currentPageIndex += count;
+            continue;
+          }
+        }
+        const kids = currentNode.get('Kids');
+        if (!Array.isArray(kids)) {
+          if ((0, _primitives.isName)(currentNode.get('Type'), 'Page') || !currentNode.has('Type') && currentNode.has('Contents')) {
+            if (currentPageIndex === pageIndex) {
+              capability.resolve([currentNode, null]);
+              return;
+            }
+            currentPageIndex++;
+            continue;
+          }
+          capability.reject(new _util.FormatError('Page dictionary kids object is not an array.'));
+          return;
+        }
+        for (let last = kids.length - 1; last >= 0; last--) {
+          nodesToVisit.push(kids[last]);
+        }
+      }
+      capability.reject(new Error(`Page index ${pageIndex} not found.`));
+    }
+    next();
+    return capability.promise;
+  }
+  getPageIndex(pageRef) {
+    const xref = this.xref;
+    function pagesBeforeRef(kidRef) {
+      let total = 0,
+          parentRef;
+      return xref.fetchAsync(kidRef).then(function (node) {
+        if ((0, _primitives.isRefsEqual)(kidRef, pageRef) && !(0, _primitives.isDict)(node, 'Page') && !((0, _primitives.isDict)(node) && !node.has('Type') && node.has('Contents'))) {
+          throw new _util.FormatError('The reference does not point to a /Page dictionary.');
+        }
+        if (!node) {
+          return null;
+        }
+        if (!(0, _primitives.isDict)(node)) {
+          throw new _util.FormatError('Node must be a dictionary.');
+        }
+        parentRef = node.getRaw('Parent');
+        return node.getAsync('Parent');
+      }).then(function (parent) {
+        if (!parent) {
+          return null;
+        }
+        if (!(0, _primitives.isDict)(parent)) {
+          throw new _util.FormatError('Parent must be a dictionary.');
+        }
+        return parent.getAsync('Kids');
+      }).then(function (kids) {
+        if (!kids) {
+          return null;
+        }
+        const kidPromises = [];
+        let found = false;
+        for (let i = 0, ii = kids.length; i < ii; i++) {
+          const kid = kids[i];
+          if (!(0, _primitives.isRef)(kid)) {
+            throw new _util.FormatError('Kid must be a reference.');
+          }
+          if ((0, _primitives.isRefsEqual)(kid, kidRef)) {
+            found = true;
+            break;
+          }
+          kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
+            if (!(0, _primitives.isDict)(kid)) {
+              throw new _util.FormatError('Kid node must be a dictionary.');
+            }
+            if (kid.has('Count')) {
+              total += kid.get('Count');
+            } else {
+              total++;
+            }
+          }));
+        }
+        if (!found) {
+          throw new _util.FormatError('Kid reference not found in parent\'s kids.');
+        }
+        return Promise.all(kidPromises).then(function () {
+          return [total, parentRef];
+        });
+      });
+    }
+    let total = 0;
+    function next(ref) {
+      return pagesBeforeRef(ref).then(function (args) {
+        if (!args) {
+          return total;
+        }
+        const [count, parentRef] = args;
+        total += count;
+        return next(parentRef);
+      });
+    }
+    return next(pageRef);
+  }
+  static parseDestDictionary(params) {
     function addDefaultProtocolToUrl(url) {
       if (url.indexOf('www.') === 0) {
-        return 'http://' + url;
+        return `http://${url}`;
       }
       return url;
     }
     function tryConvertUrlEncoding(url) {
       try {
         return (0, _util.stringToUTF8String)(url);
       } catch (e) {
         return url;
       }
     }
-    var destDict = params.destDict;
+    const destDict = params.destDict;
     if (!(0, _primitives.isDict)(destDict)) {
-      (0, _util.warn)('parseDestDictionary: "destDict" must be a dictionary.');
-      return;
-    }
-    var resultObj = params.resultObj;
+      (0, _util.warn)('parseDestDictionary: `destDict` must be a dictionary.');
+      return;
+    }
+    const resultObj = params.resultObj;
     if (typeof resultObj !== 'object') {
-      (0, _util.warn)('parseDestDictionary: "resultObj" must be an object.');
-      return;
-    }
-    var docBaseUrl = params.docBaseUrl || null;
-    var action = destDict.get('A'),
+      (0, _util.warn)('parseDestDictionary: `resultObj` must be an object.');
+      return;
+    }
+    const docBaseUrl = params.docBaseUrl || null;
+    let action = destDict.get('A'),
         url,
         dest;
     if (!(0, _primitives.isDict)(action) && destDict.has('Dest')) {
       action = destDict.get('Dest');
     }
     if ((0, _primitives.isDict)(action)) {
-      let actionType = action.get('S');
+      const actionType = action.get('S');
       if (!(0, _primitives.isName)(actionType)) {
         (0, _util.warn)('parseDestDictionary: Invalid type in Action dictionary.');
         return;
       }
-      let actionName = actionType.name;
+      const actionName = actionType.name;
       switch (actionName) {
         case 'URI':
           url = action.get('URI');
           if ((0, _primitives.isName)(url)) {
             url = '/' + url.name;
           } else if ((0, _util.isString)(url)) {
             url = addDefaultProtocolToUrl(url);
           }
           break;
         case 'GoTo':
           dest = action.get('D');
           break;
         case 'Launch':
         case 'GoToR':
-          var urlDict = action.get('F');
+          const urlDict = action.get('F');
           if ((0, _primitives.isDict)(urlDict)) {
             url = urlDict.get('F') || null;
           } else if ((0, _util.isString)(urlDict)) {
             url = urlDict;
           }
-          var remoteDest = action.get('D');
+          let remoteDest = action.get('D');
           if (remoteDest) {
             if ((0, _primitives.isName)(remoteDest)) {
               remoteDest = remoteDest.name;
             }
             if ((0, _util.isString)(url)) {
-              let baseUrl = url.split('#')[0];
+              const baseUrl = url.split('#')[0];
               if ((0, _util.isString)(remoteDest)) {
                 url = baseUrl + '#' + remoteDest;
               } else if (Array.isArray(remoteDest)) {
                 url = baseUrl + '#' + JSON.stringify(remoteDest);
               }
             }
           }
-          var newWindow = action.get('NewWindow');
+          const newWindow = action.get('NewWindow');
           if ((0, _util.isBool)(newWindow)) {
             resultObj.newWindow = newWindow;
           }
           break;
         case 'Named':
-          var namedAction = action.get('N');
+          const namedAction = action.get('N');
           if ((0, _primitives.isName)(namedAction)) {
             resultObj.action = namedAction.name;
           }
           break;
         case 'JavaScript':
-          var jsAction = action.get('JS'),
-              js;
+          const jsAction = action.get('JS');
+          let js;
           if ((0, _primitives.isStream)(jsAction)) {
             js = (0, _util.bytesToString)(jsAction.getBytes());
           } else if ((0, _util.isString)(jsAction)) {
             js = jsAction;
           }
           if (js) {
-            var URL_OPEN_METHODS = ['app.launchURL', 'window.open'];
-            var regex = new RegExp('^\\s*(' + URL_OPEN_METHODS.join('|').split('.').join('\\.') + ')\\((?:\'|\")([^\'\"]*)(?:\'|\")(?:,\\s*(\\w+)\\)|\\))', 'i');
-            var jsUrl = regex.exec((0, _util.stringToPDFString)(js));
+            const URL_OPEN_METHODS = ['app.launchURL', 'window.open'];
+            const regex = new RegExp('^\\s*(' + URL_OPEN_METHODS.join('|').split('.').join('\\.') + ')\\((?:\'|\")([^\'\"]*)(?:\'|\")(?:,\\s*(\\w+)\\)|\\))', 'i');
+            const jsUrl = regex.exec((0, _util.stringToPDFString)(js));
             if (jsUrl && jsUrl[2]) {
               url = jsUrl[2];
               if (jsUrl[3] === 'true' && jsUrl[1] === 'app.launchURL') {
                 resultObj.newWindow = true;
               }
               break;
             }
           }
         default:
-          (0, _util.warn)(`parseDestDictionary: Unsupported Action type "${actionName}".`);
+          (0, _util.warn)(`parseDestDictionary: unsupported action type "${actionName}".`);
           break;
       }
     } else if (destDict.has('Dest')) {
       dest = destDict.get('Dest');
     }
     if ((0, _util.isString)(url)) {
       url = tryConvertUrlEncoding(url);
-      var absoluteUrl = (0, _util.createValidAbsoluteUrl)(url, docBaseUrl);
+      const absoluteUrl = (0, _util.createValidAbsoluteUrl)(url, docBaseUrl);
       if (absoluteUrl) {
         resultObj.url = absoluteUrl.href;
       }
       resultObj.unsafeUrl = url;
     }
     if (dest) {
       if ((0, _primitives.isName)(dest)) {
         dest = dest.name;
       }
       if ((0, _util.isString)(dest) || Array.isArray(dest)) {
         resultObj.dest = dest;
       }
     }
-  };
-  return Catalog;
-}();
+  }
+}
 var XRef = function XRefClosure() {
   function XRef(stream, pdfManager) {
     this.stream = stream;
     this.pdfManager = pdfManager;
     this.entries = [];
     this.xrefstms = Object.create(null);
     this.cache = [];
     this.stats = {
@@ -7884,76 +7918,87 @@ var Parser = function ParserClosure() {
       if (cacheKey !== undefined) {
         imageStream.cacheKey = 'inline_' + length + '_' + cacheKey;
         this.imageCache[cacheKey] = imageStream;
       }
       this.buf2 = _primitives.Cmd.get('EI');
       this.shift();
       return imageStream;
     },
+    _findStreamLength(startPos, signature) {
+      const { stream } = this.lexer;
+      stream.pos = startPos;
+      const SCAN_BLOCK_LENGTH = 2048;
+      const signatureLength = signature.length;
+      while (stream.pos < stream.end) {
+        const scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
+        const scanLength = scanBytes.length - signatureLength;
+        if (scanLength <= 0) {
+          break;
+        }
+        let pos = 0;
+        while (pos < scanLength) {
+          let j = 0;
+          while (j < signatureLength && scanBytes[pos + j] === signature[j]) {
+            j++;
+          }
+          if (j >= signatureLength) {
+            stream.pos += pos;
+            return stream.pos - startPos;
+          }
+          pos++;
+        }
+        stream.pos += scanLength;
+      }
+      return -1;
+    },
     makeStream: function Parser_makeStream(dict, cipherTransform) {
       var lexer = this.lexer;
       var stream = lexer.stream;
       lexer.skipToNextLine();
-      var pos = stream.pos - 1;
+      const startPos = stream.pos - 1;
       var length = dict.get('Length');
       if (!Number.isInteger(length)) {
         (0, _util.info)('Bad ' + length + ' attribute in stream');
         length = 0;
       }
-      stream.pos = pos + length;
+      stream.pos = startPos + length;
       lexer.nextChar();
       if (this.tryShift() && (0, _primitives.isCmd)(this.buf2, 'endstream')) {
         this.shift();
       } else {
-        stream.pos = pos;
-        var SCAN_BLOCK_SIZE = 2048;
-        var ENDSTREAM_SIGNATURE_LENGTH = 9;
-        var ENDSTREAM_SIGNATURE = [0x65, 0x6E, 0x64, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6D];
-        var skipped = 0,
-            found = false,
-            i,
-            j;
-        while (stream.pos < stream.end) {
-          var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
-          var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
-          if (scanLength <= 0) {
-            break;
-          }
-          found = false;
-          i = 0;
-          while (i < scanLength) {
-            j = 0;
-            while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
-              j++;
-            }
-            if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
-              found = true;
-              break;
-            }
-            i++;
-          }
-          if (found) {
-            skipped += i;
-            stream.pos += i;
-            break;
-          }
-          skipped += scanLength;
-          stream.pos += scanLength;
-        }
-        if (!found) {
-          throw new _util.FormatError('Missing endstream');
-        }
-        length = skipped;
+        const ENDSTREAM_SIGNATURE = new Uint8Array([0x65, 0x6E, 0x64, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6D]);
+        let actualLength = this._findStreamLength(startPos, ENDSTREAM_SIGNATURE);
+        if (actualLength < 0) {
+          const MAX_TRUNCATION = 1;
+          for (let i = 1; i <= MAX_TRUNCATION; i++) {
+            const end = ENDSTREAM_SIGNATURE.length - i;
+            const TRUNCATED_SIGNATURE = ENDSTREAM_SIGNATURE.slice(0, end);
+            let maybeLength = this._findStreamLength(startPos, TRUNCATED_SIGNATURE);
+            if (maybeLength >= 0) {
+              const lastByte = stream.peekBytes(end + 1)[end];
+              if (!(0, _util.isSpace)(lastByte)) {
+                break;
+              }
+              (0, _util.info)(`Found "${(0, _util.bytesToString)(TRUNCATED_SIGNATURE)}" when ` + 'searching for endstream command.');
+              actualLength = maybeLength;
+              break;
+            }
+          }
+          if (actualLength < 0) {
+            throw new _util.FormatError('Missing endstream command.');
+          }
+        }
+        length = actualLength;
         lexer.nextChar();
         this.shift();
         this.shift();
       }
       this.shift();
-      stream = stream.makeSubStream(pos, length, dict);
+      stream = stream.makeSubStream(startPos, length, dict);
       if (cipherTransform) {
         stream = cipherTransform.createStream(stream, length);
       }
       stream = this.filter(stream, dict, length);
       stream.dict = dict;
       return stream;
     },
     filter: function Parser_filter(stream, dict, length) {
@@ -12396,17 +12441,22 @@ let JpegStream = function JpegStreamClos
     if ((0, _primitives.isDict)(this.params)) {
       let colorTransform = this.params.get('ColorTransform');
       if (Number.isInteger(colorTransform)) {
         jpegOptions.colorTransform = colorTransform;
       }
     }
     const jpegImage = new _jpg.JpegImage(jpegOptions);
     jpegImage.parse(this.bytes);
-    let data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
+    let data = jpegImage.getData({
+      width: this.drawWidth,
+      height: this.drawHeight,
+      forceRGB: this.forceRGB,
+      isSourcePDF: true
+    });
     this.buffer = data;
     this.bufferLength = data.length;
     this.eof = true;
   };
   JpegStream.prototype.getIR = function (forceDataSchema = false) {
     return (0, _util.createObjectURL)(this.bytes, 'image/jpeg', forceDataSchema);
   };
   return JpegStream;
@@ -13232,17 +13282,17 @@ var JpegImage = function JpegImageClosur
           scaleX: component.h / frame.maxH,
           scaleY: component.v / frame.maxV,
           blocksPerLine: component.blocksPerLine,
           blocksPerColumn: component.blocksPerColumn
         });
       }
       this.numComponents = this.components.length;
     },
-    _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
+    _getLinearizedBlockData(width, height, isSourcePDF = false) {
       var scaleX = this.width / width,
           scaleY = this.height / height;
       var component, componentScaleX, componentScaleY, blocksPerScanline;
       var x, y, i, j, k;
       var index;
       var offset = 0;
       var output;
       var numComponents = this.components.length;
@@ -13265,27 +13315,30 @@ var JpegImage = function JpegImageClosur
           j = 0 | y * componentScaleY;
           index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
           for (x = 0; x < width; x++) {
             data[offset] = output[index + xScaleBlockOffset[x]];
             offset += numComponents;
           }
         }
       }
-      const transform = this._decodeTransform;
+      let transform = this._decodeTransform;
+      if (!transform && numComponents === 4 && !isSourcePDF) {
+        transform = new Int32Array([-256, 255, -256, 255, -256, 255, -256, 255]);
+      }
       if (transform) {
         for (i = 0; i < dataLength;) {
           for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
             data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
           }
         }
       }
       return data;
     },
-    _isColorConversionNeeded() {
+    get _isColorConversionNeeded() {
       if (this.adobe) {
         return !!this.adobe.transformCode;
       }
       if (this.numComponents === 3) {
         if (this._colorTransform === 0) {
           return false;
         }
         return true;
@@ -13343,41 +13396,41 @@ var JpegImage = function JpegImageClosur
         y = data[i + 2] * scale;
         k = data[i + 3] * scale;
         data[offset++] = 255 + c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k - 285.2331026137004) + m * (1.7149763477362134 * m - 5.6096736904047315 * y - 17.873870861415444 * k - 5.497006427196366) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 17.5119270841813) - k * (21.86122147463605 * k + 189.48180835922747);
         data[offset++] = 255 + c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k - 79.2970844816548) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 190.9453302588951) + y * (4.444339102852739 * y + 9.8632861493405 * k - 24.86741582555878) - k * (20.737325471181034 * k + 187.80453709719578);
         data[offset++] = 255 + c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k - 14.183576799673286) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 112.23884253719248) + y * (0.03296041114873217 * y + 115.60384449646641 * k - 193.58209356861505) - k * (22.33816807309886 * k + 180.12613974708367);
       }
       return data.subarray(0, offset);
     },
-    getData: function getData(width, height, forceRGBoutput) {
+    getData({ width, height, forceRGB = false, isSourcePDF = false }) {
       if (this.numComponents > 4) {
         throw new JpegError('Unsupported color mode');
       }
-      var data = this._getLinearizedBlockData(width, height);
-      if (this.numComponents === 1 && forceRGBoutput) {
+      var data = this._getLinearizedBlockData(width, height, isSourcePDF);
+      if (this.numComponents === 1 && forceRGB) {
         var dataLength = data.length;
         var rgbData = new Uint8ClampedArray(dataLength * 3);
         var offset = 0;
         for (var i = 0; i < dataLength; i++) {
           var grayColor = data[i];
           rgbData[offset++] = grayColor;
           rgbData[offset++] = grayColor;
           rgbData[offset++] = grayColor;
         }
         return rgbData;
-      } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
+      } else if (this.numComponents === 3 && this._isColorConversionNeeded) {
         return this._convertYccToRgb(data);
       } else if (this.numComponents === 4) {
-        if (this._isColorConversionNeeded()) {
-          if (forceRGBoutput) {
+        if (this._isColorConversionNeeded) {
+          if (forceRGB) {
             return this._convertYcckToRgb(data);
           }
           return this._convertYcckToCmyk(data);
-        } else if (forceRGBoutput) {
+        } else if (forceRGB) {
           return this._convertCmykToRgb(data);
         }
       }
       return data;
     }
   };
   return JpegImage;
 }();
@@ -16737,176 +16790,174 @@ Object.defineProperty(exports, "__esModu
   value: true
 });
 exports.ColorSpace = undefined;
 
 var _util = __w_pdfjs_require__(2);
 
 var _primitives = __w_pdfjs_require__(12);
 
-var ColorSpace = function ColorSpaceClosure() {
-  function resizeRgbImage(src, dest, w1, h1, w2, h2, alpha01) {
-    var COMPONENTS = 3;
-    alpha01 = alpha01 !== 1 ? 0 : alpha01;
-    var xRatio = w1 / w2;
-    var yRatio = h1 / h2;
-    var i,
-        j,
-        py,
-        newIndex = 0,
-        oldIndex;
-    var xScaled = new Uint16Array(w2);
-    var w1Scanline = w1 * COMPONENTS;
-    for (i = 0; i < w2; i++) {
-      xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
-    }
-    for (i = 0; i < h2; i++) {
-      py = Math.floor(i * yRatio) * w1Scanline;
-      for (j = 0; j < w2; j++) {
-        oldIndex = py + xScaled[j];
-        dest[newIndex++] = src[oldIndex++];
-        dest[newIndex++] = src[oldIndex++];
-        dest[newIndex++] = src[oldIndex++];
-        newIndex += alpha01;
-      }
-    }
-  }
-  function ColorSpace() {
-    (0, _util.unreachable)('should not call ColorSpace constructor');
-  }
-  ColorSpace.prototype = {
-    getRgb(src, srcOffset) {
-      let rgb = new Uint8ClampedArray(3);
-      this.getRgbItem(src, srcOffset, rgb, 0);
-      return rgb;
-    },
-    getRgbItem(src, srcOffset, dest, destOffset) {
-      (0, _util.unreachable)('Should not call ColorSpace.getRgbItem');
-    },
-    getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
-      (0, _util.unreachable)('Should not call ColorSpace.getRgbBuffer');
-    },
-    getOutputLength(inputLength, alpha01) {
-      (0, _util.unreachable)('Should not call ColorSpace.getOutputLength');
-    },
-    isPassthrough(bits) {
-      return false;
-    },
-    fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
-      var count = originalWidth * originalHeight;
-      var rgbBuf = null;
-      var numComponentColors = 1 << bpc;
-      var needsResizing = originalHeight !== height || originalWidth !== width;
-      var i, ii;
-      if (this.isPassthrough(bpc)) {
-        rgbBuf = comps;
-      } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
-        var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
-        var key;
-        for (i = 0; i < numComponentColors; i++) {
-          allColors[i] = i;
-        }
-        var colorMap = new Uint8ClampedArray(numComponentColors * 3);
-        this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
-        var destPos, rgbPos;
-        if (!needsResizing) {
-          destPos = 0;
-          for (i = 0; i < count; ++i) {
-            key = comps[i] * 3;
-            dest[destPos++] = colorMap[key];
-            dest[destPos++] = colorMap[key + 1];
-            dest[destPos++] = colorMap[key + 2];
-            destPos += alpha01;
-          }
-        } else {
-          rgbBuf = new Uint8Array(count * 3);
-          rgbPos = 0;
-          for (i = 0; i < count; ++i) {
-            key = comps[i] * 3;
-            rgbBuf[rgbPos++] = colorMap[key];
-            rgbBuf[rgbPos++] = colorMap[key + 1];
-            rgbBuf[rgbPos++] = colorMap[key + 2];
-          }
-        }
-      } else {
-        if (!needsResizing) {
-          this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
-        } else {
-          rgbBuf = new Uint8ClampedArray(count * 3);
-          this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
-        }
-      }
-      if (rgbBuf) {
-        if (needsResizing) {
-          resizeRgbImage(rgbBuf, dest, originalWidth, originalHeight, width, height, alpha01);
-        } else {
-          rgbPos = 0;
-          destPos = 0;
-          for (i = 0, ii = width * actualHeight; i < ii; i++) {
-            dest[destPos++] = rgbBuf[rgbPos++];
-            dest[destPos++] = rgbBuf[rgbPos++];
-            dest[destPos++] = rgbBuf[rgbPos++];
-            destPos += alpha01;
-          }
-        }
-      }
-    },
-    usesZeroToOneRange: true
-  };
-  ColorSpace.parse = function (cs, xref, res, pdfFunctionFactory) {
-    let IR = ColorSpace.parseToIR(cs, xref, res, pdfFunctionFactory);
-    return ColorSpace.fromIR(IR);
-  };
-  ColorSpace.fromIR = function (IR) {
-    var name = Array.isArray(IR) ? IR[0] : IR;
-    var whitePoint, blackPoint, gamma;
+function resizeRgbImage(src, dest, w1, h1, w2, h2, alpha01) {
+  const COMPONENTS = 3;
+  alpha01 = alpha01 !== 1 ? 0 : alpha01;
+  let xRatio = w1 / w2;
+  let yRatio = h1 / h2;
+  let newIndex = 0,
+      oldIndex;
+  let xScaled = new Uint16Array(w2);
+  let w1Scanline = w1 * COMPONENTS;
+  for (let i = 0; i < w2; i++) {
+    xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
+  }
+  for (let i = 0; i < h2; i++) {
+    const py = Math.floor(i * yRatio) * w1Scanline;
+    for (let j = 0; j < w2; j++) {
+      oldIndex = py + xScaled[j];
+      dest[newIndex++] = src[oldIndex++];
+      dest[newIndex++] = src[oldIndex++];
+      dest[newIndex++] = src[oldIndex++];
+      newIndex += alpha01;
+    }
+  }
+}
+class ColorSpace {
+  constructor(name, numComps) {
+    if (this.constructor === ColorSpace) {
+      (0, _util.unreachable)('Cannot initialize ColorSpace.');
+    }
+    this.name = name;
+    this.numComps = numComps;
+  }
+  getRgb(src, srcOffset) {
+    let rgb = new Uint8ClampedArray(3);
+    this.getRgbItem(src, srcOffset, rgb, 0);
+    return rgb;
+  }
+  getRgbItem(src, srcOffset, dest, destOffset) {
+    (0, _util.unreachable)('Should not call ColorSpace.getRgbItem');
+  }
+  getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
+    (0, _util.unreachable)('Should not call ColorSpace.getRgbBuffer');
+  }
+  getOutputLength(inputLength, alpha01) {
+    (0, _util.unreachable)('Should not call ColorSpace.getOutputLength');
+  }
+  isPassthrough(bits) {
+    return false;
+  }
+  fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
+    let count = originalWidth * originalHeight;
+    let rgbBuf = null;
+    let numComponentColors = 1 << bpc;
+    let needsResizing = originalHeight !== height || originalWidth !== width;
+    if (this.isPassthrough(bpc)) {
+      rgbBuf = comps;
+    } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
+      let allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
+      for (let i = 0; i < numComponentColors; i++) {
+        allColors[i] = i;
+      }
+      let colorMap = new Uint8ClampedArray(numComponentColors * 3);
+      this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
+      if (!needsResizing) {
+        let destPos = 0;
+        for (let i = 0; i < count; ++i) {
+          const key = comps[i] * 3;
+          dest[destPos++] = colorMap[key];
+          dest[destPos++] = colorMap[key + 1];
+          dest[destPos++] = colorMap[key + 2];
+          destPos += alpha01;
+        }
+      } else {
+        rgbBuf = new Uint8Array(count * 3);
+        let rgbPos = 0;
+        for (let i = 0; i < count; ++i) {
+          const key = comps[i] * 3;
+          rgbBuf[rgbPos++] = colorMap[key];
+          rgbBuf[rgbPos++] = colorMap[key + 1];
+          rgbBuf[rgbPos++] = colorMap[key + 2];
+        }
+      }
+    } else {
+      if (!needsResizing) {
+        this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
+      } else {
+        rgbBuf = new Uint8ClampedArray(count * 3);
+        this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
+      }
+    }
+    if (rgbBuf) {
+      if (needsResizing) {
+        resizeRgbImage(rgbBuf, dest, originalWidth, originalHeight, width, height, alpha01);
+      } else {
+        let destPos = 0,
+            rgbPos = 0;
+        for (let i = 0, ii = width * actualHeight; i < ii; i++) {
+          dest[destPos++] = rgbBuf[rgbPos++];
+          dest[destPos++] = rgbBuf[rgbPos++];
+          dest[destPos++] = rgbBuf[rgbPos++];
+          destPos += alpha01;
+        }
+      }
+    }
+  }
+  get usesZeroToOneRange() {
+    return (0, _util.shadow)(this, 'usesZeroToOneRange', true);
+  }
+  static parse(cs, xref, res, pdfFunctionFactory) {
+    let IR = this.parseToIR(cs, xref, res, pdfFunctionFactory);
+    return this.fromIR(IR);
+  }
+  static fromIR(IR) {
+    let name = Array.isArray(IR) ? IR[0] : IR;
+    let whitePoint, blackPoint, gamma;
     switch (name) {
       case 'DeviceGrayCS':
         return this.singletons.gray;
       case 'DeviceRgbCS':
         return this.singletons.rgb;
       case 'DeviceCmykCS':
         return this.singletons.cmyk;
       case 'CalGrayCS':
         whitePoint = IR[1];
         blackPoint = IR[2];
         gamma = IR[3];
         return new CalGrayCS(whitePoint, blackPoint, gamma);
       case 'CalRGBCS':
         whitePoint = IR[1];
         blackPoint = IR[2];
         gamma = IR[3];
-        var matrix = IR[4];
+        let matrix = IR[4];
         return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
       case 'PatternCS':
-        var basePatternCS = IR[1];
+        let basePatternCS = IR[1];
         if (basePatternCS) {
-          basePatternCS = ColorSpace.fromIR(basePatternCS);
+          basePatternCS = this.fromIR(basePatternCS);
         }
         return new PatternCS(basePatternCS);
       case 'IndexedCS':
-        var baseIndexedCS = IR[1];
-        var hiVal = IR[2];
-        var lookup = IR[3];
-        return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
+        let baseIndexedCS = IR[1];
+        let hiVal = IR[2];
+        let lookup = IR[3];
+        return new IndexedCS(this.fromIR(baseIndexedCS), hiVal, lookup);
       case 'AlternateCS':
-        var numComps = IR[1];
-        var alt = IR[2];
-        var tintFn = IR[3];
-        return new AlternateCS(numComps, ColorSpace.fromIR(alt), tintFn);
+        let numComps = IR[1];
+        let alt = IR[2];
+        let tintFn = IR[3];
+        return new AlternateCS(numComps, this.fromIR(alt), tintFn);
       case 'LabCS':
         whitePoint = IR[1];
         blackPoint = IR[2];
-        var range = IR[3];
+        let range = IR[3];
         return new LabCS(whitePoint, blackPoint, range);
       default:
         throw new _util.FormatError(`Unknown colorspace name: ${name}`);
     }
-  };
-  ColorSpace.parseToIR = function (cs, xref, res = null, pdfFunctionFactory) {
+  }
+  static parseToIR(cs, xref, res = null, pdfFunctionFactory) {
     cs = xref.fetchIfRef(cs);
     if ((0, _primitives.isName)(cs)) {
       switch (cs.name) {
         case 'DeviceGray':
         case 'G':
           return 'DeviceGrayCS';
         case 'DeviceRGB':
         case 'RGB':
@@ -16918,29 +16969,29 @@ var ColorSpace = function ColorSpaceClos
           return ['PatternCS', null];
         default:
           if ((0, _primitives.isDict)(res)) {
             let colorSpaces = res.get('ColorSpace');
             if ((0, _primitives.isDict)(colorSpaces)) {
               let resCS = colorSpaces.get(cs.name);
               if (resCS) {
                 if ((0, _primitives.isName)(resCS)) {
-                  return ColorSpace.parseToIR(resCS, xref, res, pdfFunctionFactory);
+                  return this.parseToIR(resCS, xref, res, pdfFunctionFactory);
                 }
                 cs = resCS;
                 break;
               }
             }
           }
           throw new _util.FormatError(`unrecognized colorspace ${cs.name}`);
       }
     }
     if (Array.isArray(cs)) {
-      var mode = xref.fetchIfRef(cs[0]).name;
-      var numComps, params, alt, whitePoint, blackPoint, gamma;
+      let mode = xref.fetchIfRef(cs[0]).name;
+      let numComps, params, alt, whitePoint, blackPoint, gamma;
       switch (mode) {
         case 'DeviceGray':
         case 'G':
           return 'DeviceGrayCS';
         case 'DeviceRGB':
         case 'RGB':
           return 'DeviceRgbCS';
         case 'DeviceCMYK':
@@ -16952,475 +17003,381 @@ var ColorSpace = function ColorSpaceClos
           blackPoint = params.getArray('BlackPoint');
           gamma = params.get('Gamma');
           return ['CalGrayCS', whitePoint, blackPoint, gamma];
         case 'CalRGB':
           params = xref.fetchIfRef(cs[1]);
           whitePoint = params.getArray('WhitePoint');
           blackPoint = params.getArray('BlackPoint');
           gamma = params.getArray('Gamma');
-          var matrix = params.getArray('Matrix');
+          let matrix = params.getArray('Matrix');
           return ['CalRGBCS', whitePoint, blackPoint, gamma, matrix];
         case 'ICCBased':
-          var stream = xref.fetchIfRef(cs[1]);
-          var dict = stream.dict;
+          let stream = xref.fetchIfRef(cs[1]);
+          let dict = stream.dict;
           numComps = dict.get('N');
           alt = dict.get('Alternate');
           if (alt) {
-            var altIR = ColorSpace.parseToIR(alt, xref, res, pdfFunctionFactory);
-            var altCS = ColorSpace.fromIR(altIR, pdfFunctionFactory);
+            let altIR = this.parseToIR(alt, xref, res, pdfFunctionFactory);
+            let altCS = this.fromIR(altIR, pdfFunctionFactory);
             if (altCS.numComps === numComps) {
               return altIR;
             }
             (0, _util.warn)('ICCBased color space: Ignoring incorrect /Alternate entry.');
           }
           if (numComps === 1) {
             return 'DeviceGrayCS';
           } else if (numComps === 3) {
             return 'DeviceRgbCS';
           } else if (numComps === 4) {
             return 'DeviceCmykCS';
           }
           break;
         case 'Pattern':
-          var basePatternCS = cs[1] || null;
+          let basePatternCS = cs[1] || null;
           if (basePatternCS) {
-            basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res, pdfFunctionFactory);
+            basePatternCS = this.parseToIR(basePatternCS, xref, res, pdfFunctionFactory);
           }
           return ['PatternCS', basePatternCS];
         case 'Indexed':
         case 'I':
-          var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res, pdfFunctionFactory);
-          var hiVal = xref.fetchIfRef(cs[2]) + 1;
-          var lookup = xref.fetchIfRef(cs[3]);
+          let baseIndexedCS = this.parseToIR(cs[1], xref, res, pdfFunctionFactory);
+          let hiVal = xref.fetchIfRef(cs[2]) + 1;
+          let lookup = xref.fetchIfRef(cs[3]);
           if ((0, _primitives.isStream)(lookup)) {
             lookup = lookup.getBytes();
           }
           return ['IndexedCS', baseIndexedCS, hiVal, lookup];
         case 'Separation':
         case 'DeviceN':
-          var name = xref.fetchIfRef(cs[1]);
+          let name = xref.fetchIfRef(cs[1]);
           numComps = Array.isArray(name) ? name.length : 1;
-          alt = ColorSpace.parseToIR(cs[2], xref, res, pdfFunctionFactory);
+          alt = this.parseToIR(cs[2], xref, res, pdfFunctionFactory);
           let tintFn = pdfFunctionFactory.create(xref.fetchIfRef(cs[3]));
           return ['AlternateCS', numComps, alt, tintFn];
         case 'Lab':
           params = xref.fetchIfRef(cs[1]);
           whitePoint = params.getArray('WhitePoint');
           blackPoint = params.getArray('BlackPoint');
-          var range = params.getArray('Range');
+          let range = params.getArray('Range');
           return ['LabCS', whitePoint, blackPoint, range];
         default:
           throw new _util.FormatError(`unimplemented color space object "${mode}"`);
       }
     }
     throw new _util.FormatError(`unrecognized color space object: "${cs}"`);
-  };
-  ColorSpace.isDefaultDecode = function (decode, n) {
+  }
+  static isDefaultDecode(decode, n) {
     if (!Array.isArray(decode)) {
       return true;
     }
     if (n * 2 !== decode.length) {
       (0, _util.warn)('The decode map is not the correct length');
       return true;
     }
-    for (var i = 0, ii = decode.length; i < ii; i += 2) {
+    for (let i = 0, ii = decode.length; i < ii; i += 2) {
       if (decode[i] !== 0 || decode[i + 1] !== 1) {
         return false;
       }
     }
     return true;
-  };
-  ColorSpace.singletons = {
-    get gray() {
-      return (0, _util.shadow)(this, 'gray', new DeviceGrayCS());
-    },
-    get rgb() {
-      return (0, _util.shadow)(this, 'rgb', new DeviceRgbCS());
-    },
-    get cmyk() {
-      return (0, _util.shadow)(this, 'cmyk', new DeviceCmykCS());
-    }
-  };
-  return ColorSpace;
-}();
-var AlternateCS = function AlternateCSClosure() {
-  function AlternateCS(numComps, base, tintFn) {
-    this.name = 'Alternate';
-    this.numComps = numComps;
-    this.defaultColor = new Float32Array(numComps);
-    for (var i = 0; i < numComps; ++i) {
-      this.defaultColor[i] = 1;
-    }
+  }
+  static get singletons() {
+    return (0, _util.shadow)(this, 'singletons', {
+      get gray() {
+        return (0, _util.shadow)(this, 'gray', new DeviceGrayCS());
+      },
+      get rgb() {
+        return (0, _util.shadow)(this, 'rgb', new DeviceRgbCS());
+      },
+      get cmyk() {
+        return (0, _util.shadow)(this, 'cmyk', new DeviceCmykCS());
+      }
+    });
+  }
+}
+class AlternateCS extends ColorSpace {
+  constructor(numComps, base, tintFn) {
+    super('Alternate', numComps);
     this.base = base;
     this.tintFn = tintFn;
     this.tmpBuf = new Float32Array(base.numComps);
   }
-  AlternateCS.prototype = {
-    getRgb: ColorSpace.prototype.getRgb,
-    getRgbItem(src, srcOffset, dest, destOffset) {
-      var tmpBuf = this.tmpBuf;
-      this.tintFn(src, srcOffset, tmpBuf, 0);
-      this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
-    },
-    getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
-      var tintFn = this.tintFn;
-      var base = this.base;
-      var scale = 1 / ((1 << bits) - 1);
-      var baseNumComps = base.numComps;
-      var usesZeroToOneRange = base.usesZeroToOneRange;
-      var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
-      var pos = isPassthrough ? destOffset : 0;
-      let baseBuf = isPassthrough ? dest : new Uint8ClampedArray(baseNumComps * count);
-      var numComps = this.numComps;
-      var scaled = new Float32Array(numComps);
-      var tinted = new Float32Array(baseNumComps);
-      var i, j;
-      for (i = 0; i < count; i++) {
-        for (j = 0; j < numComps; j++) {
-          scaled[j] = src[srcOffset++] * scale;
-        }
-        tintFn(scaled, 0, tinted, 0);
-        if (usesZeroToOneRange) {
-          for (j = 0; j < baseNumComps; j++) {
-            baseBuf[pos++] = tinted[j] * 255;
-          }
-        } else {
-          base.getRgbItem(tinted, 0, baseBuf, pos);
-          pos += baseNumComps;
-        }
-      }
-      if (!isPassthrough) {
-        base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
-      }
-    },
-    getOutputLength(inputLength, alpha01) {
-      return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
-    },
-    isPassthrough: ColorSpace.prototype.isPassthrough,
-    fillRgb: ColorSpace.prototype.fillRgb,
-    isDefaultDecode(decodeMap) {
-      return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
-    },
-    usesZeroToOneRange: true
-  };
-  return AlternateCS;
-}();
-var PatternCS = function PatternCSClosure() {
-  function PatternCS(baseCS) {
-    this.name = 'Pattern';
+  getRgbItem(src, srcOffset, dest, destOffset) {
+    let tmpBuf = this.tmpBuf;
+    this.tintFn(src, srcOffset, tmpBuf, 0);
+    this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
+  }
+  getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
+    let tintFn = this.tintFn;
+    let base = this.base;
+    let scale = 1 / ((1 << bits) - 1);
+    let baseNumComps = base.numComps;
+    let usesZeroToOneRange = base.usesZeroToOneRange;
+    let isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
+    let pos = isPassthrough ? destOffset : 0;
+    let baseBuf = isPassthrough ? dest : new Uint8ClampedArray(baseNumComps * count);
+    let numComps = this.numComps;
+    let scaled = new Float32Array(numComps);
+    let tinted = new Float32Array(baseNumComps);
+    let i, j;
+    for (i = 0; i < count; i++) {
+      for (j = 0; j < numComps; j++) {
+        scaled[j] = src[srcOffset++] * scale;
+      }
+      tintFn(scaled, 0, tinted, 0);
+      if (usesZeroToOneRange) {
+        for (j = 0; j < baseNumComps; j++) {
+          baseBuf[pos++] = tinted[j] * 255;
+        }
+      } else {
+        base.getRgbItem(tinted, 0, baseBuf, pos);
+        pos += baseNumComps;
+      }
+    }
+    if (!isPassthrough) {
+      base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
+    }
+  }
+  getOutputLength(inputLength, alpha01) {
+    return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
+  }
+  isDefaultDecode(decodeMap) {
+    return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
+  }
+}
+class PatternCS extends ColorSpace {
+  constructor(baseCS) {
+    super('Pattern', null);
     this.base = baseCS;
   }
-  PatternCS.prototype = {};
-  return PatternCS;
-}();
-var IndexedCS = function IndexedCSClosure() {
-  function IndexedCS(base, highVal, lookup) {
-    this.name = 'Indexed';
-    this.numComps = 1;
-    this.defaultColor = new Uint8Array(this.numComps);
+}
+class IndexedCS extends ColorSpace {
+  constructor(base, highVal, lookup) {
+    super('Indexed', 1);
     this.base = base;
     this.highVal = highVal;
-    var baseNumComps = base.numComps;
-    var length = baseNumComps * highVal;
+    let baseNumComps = base.numComps;
+    let length = baseNumComps * highVal;
     if ((0, _primitives.isStream)(lookup)) {
       this.lookup = new Uint8Array(length);
-      var bytes = lookup.getBytes(length);
+      let bytes = lookup.getBytes(length);
       this.lookup.set(bytes);
     } else if ((0, _util.isString)(lookup)) {
       this.lookup = new Uint8Array(length);
-      for (var i = 0; i < length; ++i) {
+      for (let i = 0; i < length; ++i) {
         this.lookup[i] = lookup.charCodeAt(i);
       }
     } else if (lookup instanceof Uint8Array) {
       this.lookup = lookup;
     } else {
       throw new _util.FormatError(`Unrecognized lookup table: ${lookup}`);
     }
   }
-  IndexedCS.prototype = {
-    getRgb: ColorSpace.prototype.getRgb,
-    getRgbItem(src, srcOffset, dest, destOffset) {
-      var numComps = this.base.numComps;
-      var start = src[srcOffset] * numComps;
-      this.base.getRgbBuffer(this.lookup, start, 1, dest, destOffset, 8, 0);
-    },
-    getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
-      var base = this.base;
-      var numComps = base.numComps;
-      var outputDelta = base.getOutputLength(numComps, alpha01);
-      var lookup = this.lookup;
-      for (var i = 0; i < count; ++i) {
-        var lookupPos = src[srcOffset++] * numComps;
-        base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
-        destOffset += outputDelta;
-      }
-    },
-    getOutputLength(inputLength, alpha01) {
-      return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
-    },
-    isPassthrough: ColorSpace.prototype.isPassthrough,
-    fillRgb: ColorSpace.prototype.fillRgb,
-    isDefaultDecode(decodeMap) {
-      return true;
-    },
-    usesZeroToOneRange: true
-  };
-  return IndexedCS;
-}();
-var DeviceGrayCS = function DeviceGrayCSClosure() {
-  function DeviceGrayCS() {
-    this.name = 'DeviceGray';
-    this.numComps = 1;
-    this.defaultColor = new Float32Array(this.numComps);
-  }
-  DeviceGrayCS.prototype = {
-    getRgb: ColorSpace.prototype.getRgb,
-    getRgbItem(src, srcOffset, dest, destOffset) {
-      let c = src[srcOffset] * 255;
-      dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
-    },
-    getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
-      var scale = 255 / ((1 << bits) - 1);
-      var j = srcOffset,
-          q = destOffset;
-      for (var i = 0; i < count; ++i) {
-        let c = scale * src[j++];
-        dest[q++] = c;
-        dest[q++] = c;
-        dest[q++] = c;
-        q += alpha01;
-      }
-    },
-    getOutputLength(inputLength, alpha01) {
-      return inputLength * (3 + alpha01);
-    },
-    isPassthrough: ColorSpace.prototype.isPassthrough,
-    fillRgb: ColorSpace.prototype.fillRgb,
-    isDefaultDecode(decodeMap) {
-      return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
-    },
-    usesZeroToOneRange: true
-  };
-  return DeviceGrayCS;
-}();
-var DeviceRgbCS = function DeviceRgbCSClosure() {
-  function DeviceRgbCS() {
-    this.name = 'DeviceRGB';
-    this.numComps = 3;
-    this.defaultColor = new Float32Array(this.numComps);
-  }
-  DeviceRgbCS.prototype = {
-    getRgb: ColorSpace.prototype.getRgb,
-    getRgbItem(src, srcOffset, dest, destOffset) {
-      dest[destOffset] = src[srcOffset] * 255;
-      dest[destOffset + 1] = src[srcOffset + 1] * 255;
-      dest[destOffset + 2] = src[srcOffset + 2] * 255;
-    },
-    getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
-      if (bits === 8 && alpha01 === 0) {
-        dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
-        return;
-      }
-      var scale = 255 / ((1 << bits) - 1);
-      var j = srcOffset,
-          q = destOffset;
-      for (var i = 0; i < count; ++i) {
-        dest[q++] = scale * src[j++];
-        dest[q++] = scale * src[j++];
-        dest[q++] = scale * src[j++];
-        q += alpha01;
-      }
-    },
-    getOutputLength(inputLength, alpha01) {
-      return inputLength * (3 + alpha01) / 3 | 0;
-    },
-    isPassthrough(bits) {
-      return bits === 8;
-    },
-    fillRgb: ColorSpace.prototype.fillRgb,
-    isDefaultDecode(decodeMap) {
-      return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
-    },
-    usesZeroToOneRange: true
-  };
-  return DeviceRgbCS;
-}();
-var DeviceCmykCS = function DeviceCmykCSClosure() {
+  getRgbItem(src, srcOffset, dest, destOffset) {
+    let numComps = this.base.numComps;
+    let start = src[srcOffset] * numComps;
+    this.base.getRgbBuffer(this.lookup, start, 1, dest, destOffset, 8, 0);
+  }
+  getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
+    let base = this.base;
+    let numComps = base.numComps;
+    let outputDelta = base.getOutputLength(numComps, alpha01);
+    let lookup = this.lookup;
+    for (let i = 0; i < count; ++i) {
+      let lookupPos = src[srcOffset++] * numComps;
+      base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
+      destOffset += outputDelta;
+    }
+  }
+  getOutputLength(inputLength, alpha01) {
+    return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
+  }
+  isDefaultDecode(decodeMap) {
+    return true;
+  }
+}
+class DeviceGrayCS extends ColorSpace {
+  constructor() {
+    super('DeviceGray', 1);
+  }
+  getRgbItem(src, srcOffset, dest, destOffset) {
+    let c = src[srcOffset] * 255;
+    dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
+  }
+  getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
+    let scale = 255 / ((1 << bits) - 1);
+    let j = srcOffset,
+        q = destOffset;
+    for (let i = 0; i < count; ++i) {
+      let c = scale * src[j++];
+      dest[q++] = c;
+      dest[q++] = c;
+      dest[q++] = c;
+      q += alpha01;
+    }
+  }
+  getOutputLength(inputLength, alpha01) {
+    return inputLength * (3 + alpha01);
+  }
+  isDefaultDecode(decodeMap) {
+    return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
+  }
+}
+class DeviceRgbCS extends ColorSpace {
+  constructor() {
+    super('DeviceRGB', 3);
+  }
+  getRgbItem(src, srcOffset, dest, destOffset) {
+    dest[destOffset] = src[srcOffset] * 255;
+    dest[destOffset + 1] = src[srcOffset + 1] * 255;
+    dest[destOffset + 2] = src[srcOffset + 2] * 255;
+  }
+  getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
+    if (bits === 8 && alpha01 === 0) {
+      dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
+      return;
+    }
+    let scale = 255 / ((1 << bits) - 1);
+    let j = srcOffset,
+        q = destOffset;
+    for (let i = 0; i < count; ++i) {
+      dest[q++] = scale * src[j++];
+      dest[q++] = scale * src[j++];
+      dest[q++] = scale * src[j++];
+      q += alpha01;
+    }
+  }
+  getOutputLength(inputLength, alpha01) {
+    return inputLength * (3 + alpha01) / 3 | 0;
+  }
+  isPassthrough(bits) {
+    return bits === 8;
+  }
+  isDefaultDecode(decodeMap) {
+    return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
+  }
+}
+const DeviceCmykCS = function DeviceCmykCSClosure() {
   function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
-    var c = src[srcOffset] * srcScale;
-    var m = src[srcOffset + 1] * srcScale;
-    var y = src[srcOffset + 2] * srcScale;
-    var k = src[srcOffset + 3] * srcScale;
+    let c = src[srcOffset] * srcScale;
+    let m = src[srcOffset + 1] * srcScale;
+    let y = src[srcOffset + 2] * srcScale;
+    let k = src[srcOffset + 3] * srcScale;
     dest[destOffset] = 255 + c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k + -285.2331026137004) + m * (1.7149763477362134 * m - 5.6096736904047315 * y + -17.873870861415444 * k - 5.497006427196366) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 17.5119270841813) + k * (-21.86122147463605 * k - 189.48180835922747);
     dest[destOffset + 1] = 255 + c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k + -79.2970844816548) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 190.9453302588951) + y * (4.444339102852739 * y + 9.8632861493405 * k - 24.86741582555878) + k * (-20.737325471181034 * k - 187.80453709719578);
     dest[destOffset + 2] = 255 + c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k + -14.183576799673286) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 112.23884253719248) + y * (0.03296041114873217 * y + 115.60384449646641 * k + -193.58209356861505) + k * (-22.33816807309886 * k - 180.12613974708367);
   }
-  function DeviceCmykCS() {
-    this.name = 'DeviceCMYK';
-    this.numComps = 4;
-    this.defaultColor = new Float32Array(this.numComps);
-    this.defaultColor[3] = 1;
-  }
-  DeviceCmykCS.prototype = {
-    getRgb: ColorSpace.prototype.getRgb,
+  class DeviceCmykCS extends ColorSpace {
+    constructor() {
+      super('DeviceCMYK', 4);
+    }
     getRgbItem(src, srcOffset, dest, destOffset) {
       convertToRgb(src, srcOffset, 1, dest, destOffset);
-    },
+    }
     getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
-      var scale = 1 / ((1 << bits) - 1);
-      for (var i = 0; i < count; i++) {
+      let scale = 1 / ((1 << bits) - 1);
+      for (let i = 0; i < count; i++) {
         convertToRgb(src, srcOffset, scale, dest, destOffset);
         srcOffset += 4;
         destOffset += 3 + alpha01;
       }
-    },
+    }
     getOutputLength(inputLength, alpha01) {
       return inputLength / 4 * (3 + alpha01) | 0;
-    },
-    isPassthrough: ColorSpace.prototype.isPassthrough,
-    fillRgb: ColorSpace.prototype.fillRgb,
+    }
     isDefaultDecode(decodeMap) {
       return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
-    },
-    usesZeroToOneRange: true
-  };
+    }
+  }
   return DeviceCmykCS;
 }();
-var CalGrayCS = function CalGrayCSClosure() {
-  function CalGrayCS(whitePoint, blackPoint, gamma) {
-    this.name = 'CalGray';
-    this.numComps = 1;
-    this.defaultColor = new Float32Array(this.numComps);
-    if (!whitePoint) {
-      throw new _util.FormatError('WhitePoint missing - required for color space CalGray');
-    }
-    blackPoint = blackPoint || [0, 0, 0];
-    gamma = gamma || 1;
-    this.XW = whitePoint[0];
-    this.YW = whitePoint[1];
-    this.ZW = whitePoint[2];
-    this.XB = blackPoint[0];
-    this.YB = blackPoint[1];
-    this.ZB = blackPoint[2];
-    this.G = gamma;
-    if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
-      throw new _util.FormatError(`Invalid WhitePoint components for ${this.name}` + ', no fallback available');
-    }
-    if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
-      (0, _util.info)('Invalid BlackPoint for ' + this.name + ', falling back to default');
-      this.XB = this.YB = this.ZB = 0;
-    }
-    if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
-      (0, _util.warn)(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
-    }
-    if (this.G < 1) {
-      (0, _util.info)('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
-      this.G = 1;
-    }
-  }
+const CalGrayCS = function CalGrayCSClosure() {
   function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
-    var A = src[srcOffset] * scale;
-    var AG = Math.pow(A, cs.G);
-    var L = cs.YW * AG;
+    let A = src[srcOffset] * scale;
+    let AG = Math.pow(A, cs.G);
+    let L = cs.YW * AG;
     let val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0);
     dest[destOffset] = val;
     dest[destOffset + 1] = val;
     dest[destOffset + 2] = val;
   }
-  CalGrayCS.prototype = {
-    getRgb: ColorSpace.prototype.getRgb,
+  class CalGrayCS extends ColorSpace {
+    constructor(whitePoint, blackPoint, gamma) {
+      super('CalGray', 1);
+      if (!whitePoint) {
+        throw new _util.FormatError('WhitePoint missing - required for color space CalGray');
+      }
+      blackPoint = blackPoint || [0, 0, 0];
+      gamma = gamma || 1;
+      this.XW = whitePoint[0];
+      this.YW = whitePoint[1];
+      this.ZW = whitePoint[2];
+      this.XB = blackPoint[0];
+      this.YB = blackPoint[1];
+      this.ZB = blackPoint[2];
+      this.G = gamma;
+      if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
+        throw new _util.FormatError(`Invalid WhitePoint components for ${this.name}` + ', no fallback available');
+      }
+      if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
+        (0, _util.info)(`Invalid BlackPoint for ${this.name}, falling back to default.`);
+        this.XB = this.YB = this.ZB = 0;
+      }
+      if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
+        (0, _util.warn)(`${this.name}, BlackPoint: XB: ${this.XB}, YB: ${this.YB}, ` + `ZB: ${this.ZB}, only default values are supported.`);
+      }
+      if (this.G < 1) {
+        (0, _util.info)(`Invalid Gamma: ${this.G} for ${this.name}, ` + 'falling back to default.');
+        this.G = 1;
+      }
+    }
     getRgbItem(src, srcOffset, dest, destOffset) {
       convertToRgb(this, src, srcOffset, dest, destOffset, 1);
-    },
+    }
     getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
-      var scale = 1 / ((1 << bits) - 1);
-      for (var i = 0; i < count; ++i) {
+      let scale = 1 / ((1 << bits) - 1);
+      for (let i = 0; i < count; ++i) {
         convertToRgb(this, src, srcOffset, dest, destOffset, scale);
         srcOffset += 1;
         destOffset += 3 + alpha01;
       }
-    },
+    }
     getOutputLength(inputLength, alpha01) {
       return inputLength * (3 + alpha01);
-    },
-    isPassthrough: ColorSpace.prototype.isPassthrough,
-    fillRgb: ColorSpace.prototype.fillRgb,
+    }
     isDefaultDecode(decodeMap) {
       return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
-    },
-    usesZeroToOneRange: true
-  };
+    }
+  }
   return CalGrayCS;
 }();
-var CalRGBCS = function CalRGBCSClosure() {
-  var BRADFORD_SCALE_MATRIX = new Float32Array([0.8951, 0.2664, -0.1614, -0.7502, 1.7135, 0.0367, 0.0389, -0.0685, 1.0296]);
-  var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([0.9869929, -0.1470543, 0.1599627, 0.4323053, 0.5183603, 0.0492912, -0.0085287, 0.0400428, 0.9684867]);
-  var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([3.2404542, -1.5371385, -0.4985314, -0.9692660, 1.8760108, 0.0415560, 0.0556434, -0.2040259, 1.0572252]);
-  var FLAT_WHITEPOINT_MATRIX = new Float32Array([1, 1, 1]);
-  var tempNormalizeMatrix = new Float32Array(3);
-  var tempConvertMatrix1 = new Float32Array(3);
-  var tempConvertMatrix2 = new Float32Array(3);
-  var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
-  function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
-    this.name = 'CalRGB';
-    this.numComps = 3;
-    this.defaultColor = new Float32Array(this.numComps);
-    if (!whitePoint) {
-      throw new _util.FormatError('WhitePoint missing - required for color space CalRGB');
-    }
-    blackPoint = blackPoint || new Float32Array(3);
-    gamma = gamma || new Float32Array([1, 1, 1]);
-    matrix = matrix || new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
-    var XW = whitePoint[0];
-    var YW = whitePoint[1];
-    var ZW = whitePoint[2];
-    this.whitePoint = whitePoint;
-    var XB = blackPoint[0];
-    var YB = blackPoint[1];
-    var ZB = blackPoint[2];
-    this.blackPoint = blackPoint;
-    this.GR = gamma[0];
-    this.GG = gamma[1];
-    this.GB = gamma[2];
-    this.MXA = matrix[0];
-    this.MYA = matrix[1];
-    this.MZA = matrix[2];
-    this.MXB = matrix[3];
-    this.MYB = matrix[4];
-    this.MZB = matrix[5];
-    this.MXC = matrix[6];
-    this.MYC = matrix[7];
-    this.MZC = matrix[8];
-    if (XW < 0 || ZW < 0 || YW !== 1) {
-      throw new _util.FormatError(`Invalid WhitePoint components for ${this.name}` + ', no fallback available');
-    }
-    if (XB < 0 || YB < 0 || ZB < 0) {
-      (0, _util.info)('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
-      this.blackPoint = new Float32Array(3);
-    }
-    if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
-      (0, _util.info)('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
-      this.GR = this.GG = this.GB = 1;
-    }
-  }
+const CalRGBCS = function CalRGBCSClosure() {
+  const BRADFORD_SCALE_MATRIX = new Float32Array([0.8951, 0.2664, -0.1614, -0.7502, 1.7135, 0.0367, 0.0389, -0.0685, 1.0296]);
+  const BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([0.9869929, -0.1470543, 0.1599627, 0.4323053, 0.5183603, 0.0492912, -0.0085287, 0.0400428, 0.9684867]);
+  const SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([3.2404542, -1.5371385, -0.4985314, -0.9692660, 1.8760108, 0.0415560, 0.0556434, -0.2040259, 1.0572252]);
+  const FLAT_WHITEPOINT_MATRIX = new Float32Array([1, 1, 1]);
+  let tempNormalizeMatrix = new Float32Array(3);
+  let tempConvertMatrix1 = new Float32Array(3);
+  let tempConvertMatrix2 = new Float32Array(3);
+  const DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
   function matrixProduct(a, b, result) {
     result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
     result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
     result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
   }
   function convertToFlat(sourceWhitePoint, LMS, result) {
     result[0] = LMS[0] * 1 / sourceWhitePoint[0];
     result[1] = LMS[1] * 1 / sourceWhitePoint[1];
     result[2] = LMS[2] * 1 / sourceWhitePoint[2];
   }
   function convertToD65(sourceWhitePoint, LMS, result) {
-    var D65X = 0.95047;
-    var D65Y = 1;
-    var D65Z = 1.08883;
+    const D65X = 0.95047;
+    const D65Y = 1;
+    const D65Z = 1.08883;
     result[0] = LMS[0] * D65X / sourceWhitePoint[0];
     result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
     result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
   }
   function sRGBTransferFunction(color) {
     if (color <= 0.0031308) {
       return adjustToRange(0, 1, 12.92 * color);
     }
@@ -17440,205 +17397,238 @@ var CalRGBCS = function CalRGBCSClosure(
   }
   function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
     if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
       result[0] = XYZ_Flat[0];
       result[1] = XYZ_Flat[1];
       result[2] = XYZ_Flat[2];
       return;
     }
-    var zeroDecodeL = decodeL(0);
-    var X_DST = zeroDecodeL;
-    var X_SRC = decodeL(sourceBlackPoint[0]);
-    var Y_DST = zeroDecodeL;
-    var Y_SRC = decodeL(sourceBlackPoint[1]);
-    var Z_DST = zeroDecodeL;
-    var Z_SRC = decodeL(sourceBlackPoint[2]);
-    var X_Scale = (1 - X_DST) / (1 - X_SRC);
-    var X_Offset = 1 - X_Scale;
-    var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
-    var Y_Offset = 1 - Y_Scale;
-    var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
-    var Z_Offset = 1 - Z_Scale;
+    let zeroDecodeL = decodeL(0);
+    let X_DST = zeroDecodeL;
+    let X_SRC = decodeL(sourceBlackPoint[0]);
+    let Y_DST = zeroDecodeL;
+    let Y_SRC = decodeL(sourceBlackPoint[1]);
+    let Z_DST = zeroDecodeL;
+    let Z_SRC = decodeL(sourceBlackPoint[2]);
+    let X_Scale = (1 - X_DST) / (1 - X_SRC);
+    let X_Offset = 1 - X_Scale;
+    let Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
+    let Y_Offset = 1 - Y_Scale;
+    let Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
+    let Z_Offset = 1 - Z_Scale;
     result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
     result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
     result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
   }
   function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
     if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
       result[0] = XYZ_In[0];
       result[1] = XYZ_In[1];
       result[2] = XYZ_In[2];
       return;
     }
-    var LMS = result;
+    let LMS = result;
     matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
-    var LMS_Flat = tempNormalizeMatrix;
+    let LMS_Flat = tempNormalizeMatrix;
     convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
     matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
   }
   function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
-    var LMS = result;
+    let LMS = result;
     matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
-    var LMS_D65 = tempNormalizeMatrix;
+    let LMS_D65 = tempNormalizeMatrix;
     convertToD65(sourceWhitePoint, LMS, LMS_D65);
     matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
   }
   function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
-    var A = adjustToRange(0, 1, src[srcOffset] * scale);
-    var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
-    var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
-    var AGR = Math.pow(A, cs.GR);
-    var BGG = Math.pow(B, cs.GG);
-    var CGB = Math.pow(C, cs.GB);
-    var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
-    var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
-    var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
-    var XYZ = tempConvertMatrix1;
+    let A = adjustToRange(0, 1, src[srcOffset] * scale);
+    let B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
+    let C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
+    let AGR = Math.pow(A, cs.GR);
+    let BGG = Math.pow(B, cs.GG);
+    let CGB = Math.pow(C, cs.GB);
+    let X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
+    let Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
+    let Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
+    let XYZ = tempConvertMatrix1;
     XYZ[0] = X;
     XYZ[1] = Y;
     XYZ[2] = Z;
-    var XYZ_Flat = tempConvertMatrix2;
+    let XYZ_Flat = tempConvertMatrix2;
     normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
-    var XYZ_Black = tempConvertMatrix1;
+    let XYZ_Black = tempConvertMatrix1;
     compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
-    var XYZ_D65 = tempConvertMatrix2;
+    let XYZ_D65 = tempConvertMatrix2;
     normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
-    var SRGB = tempConvertMatrix1;
+    let SRGB = tempConvertMatrix1;
     matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
     dest[destOffset] = sRGBTransferFunction(SRGB[0]) * 255;
     dest[destOffset + 1] = sRGBTransferFunction(SRGB[1]) * 255;
     dest[destOffset + 2] = sRGBTransferFunction(SRGB[2]) * 255;
   }
-  CalRGBCS.prototype = {
-    getRgb: ColorSpace.prototype.getRgb,
+  class CalRGBCS extends ColorSpace {
+    constructor(whitePoint, blackPoint, gamma, matrix) {
+      super('CalRGB', 3);
+      if (!whitePoint) {
+        throw new _util.FormatError('WhitePoint missing - required for color space CalRGB');
+      }
+      blackPoint = blackPoint || new Float32Array(3);
+      gamma = gamma || new Float32Array([1, 1, 1]);
+      matrix = matrix || new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
+      let XW = whitePoint[0];
+      let YW = whitePoint[1];
+      let ZW = whitePoint[2];
+      this.whitePoint = whitePoint;
+      let XB = blackPoint[0];
+      let YB = blackPoint[1];
+      let ZB = blackPoint[2];
+      this.blackPoint = blackPoint;
+      this.GR = gamma[0];
+      this.GG = gamma[1];
+      this.GB = gamma[2];
+      this.MXA = matrix[0];
+      this.MYA = matrix[1];
+      this.MZA = matrix[2];
+      this.MXB = matrix[3];
+      this.MYB = matrix[4];
+      this.MZB = matrix[5];
+      this.MXC = matrix[6];
+      this.MYC = matrix[7];
+      this.MZC = matrix[8];
+      if (XW < 0 || ZW < 0 || YW !== 1) {
+        throw new _util.FormatError(`Invalid WhitePoint components for ${this.name}` + ', no fallback available');
+      }
+      if (XB < 0 || YB < 0 || ZB < 0) {
+        (0, _util.info)(`Invalid BlackPoint for ${this.name} [${XB}, ${YB}, ${ZB}], ` + 'falling back to default.');
+        this.blackPoint = new Float32Array(3);
+      }
+      if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
+        (0, _util.info)(`Invalid Gamma [${this.GR}, ${this.GG}, ${this.GB}] for ` + `${this.name}, falling back to default.`);
+        this.GR = this.GG = this.GB = 1;
+      }
+    }
     getRgbItem(src, srcOffset, dest, destOffset) {
       convertToRgb(this, src, srcOffset, dest, destOffset, 1);
-    },
+    }
     getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
-      var scale = 1 / ((1 << bits) - 1);
-      for (var i = 0; i < count; ++i) {
+      let scale = 1 / ((1 << bits) - 1);
+      for (let i = 0; i < count; ++i) {
         convertToRgb(this, src, srcOffset, dest, destOffset, scale);
         srcOffset += 3;
         destOffset += 3 + alpha01;
       }
-    },
+    }
     getOutputLength(inputLength, alpha01) {
       return inputLength * (3 + alpha01) / 3 | 0;
-    },
-    isPassthrough: ColorSpace.prototype.isPassthrough,
-    fillRgb: ColorSpace.prototype.fillRgb,
+    }
     isDefaultDecode(decodeMap) {
       return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
-    },
-    usesZeroToOneRange: true
-  };
+    }
+  }
   return CalRGBCS;
 }();
-var LabCS = function LabCSClosure() {
-  function LabCS(whitePoint, blackPoint, range) {
-    this.name = 'Lab';
-    this.numComps = 3;
-    this.defaultColor = new Float32Array(this.numComps);
-    if (!whitePoint) {
-      throw new _util.FormatError('WhitePoint missing - required for color space Lab');
-    }
-    blackPoint = blackPoint || [0, 0, 0];
-    range = range || [-100, 100, -100, 100];
-    this.XW = whitePoint[0];
-    this.YW = whitePoint[1];
-    this.ZW = whitePoint[2];
-    this.amin = range[0];
-    this.amax = range[1];
-    this.bmin = range[2];
-    this.bmax = range[3];
-    this.XB = blackPoint[0];
-    this.YB = blackPoint[1];
-    this.ZB = blackPoint[2];
-    if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
-      throw new _util.FormatError('Invalid WhitePoint components, no fallback available');
-    }
-    if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
-      (0, _util.info)('Invalid BlackPoint, falling back to default');
-      this.XB = this.YB = this.ZB = 0;
-    }
-    if (this.amin > this.amax || this.bmin > this.bmax) {
-      (0, _util.info)('Invalid Range, falling back to defaults');
-      this.amin = -100;
-      this.amax = 100;
-      this.bmin = -100;
-      this.bmax = 100;
-    }
-  }
+const LabCS = function LabCSClosure() {
   function fn_g(x) {
-    var result;
+    let result;
     if (x >= 6 / 29) {
       result = x * x * x;
     } else {
       result = 108 / 841 * (x - 4 / 29);
     }
     return result;
   }
   function decode(value, high1, low2, high2) {
     return low2 + value * (high2 - low2) / high1;
   }
   function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
-    var Ls = src[srcOffset];
-    var as = src[srcOffset + 1];
-    var bs = src[srcOffset + 2];
+    let Ls = src[srcOffset];
+    let as = src[srcOffset + 1];
+    let bs = src[srcOffset + 2];
     if (maxVal !== false) {
       Ls = decode(Ls, maxVal, 0, 100);
       as = decode(as, maxVal, cs.amin, cs.amax);
       bs = decode(bs, maxVal, cs.bmin, cs.bmax);
     }
     as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
     bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
-    var M = (Ls + 16) / 116;
-    var L = M + as / 500;
-    var N = M - bs / 200;
-    var X = cs.XW * fn_g(L);
-    var Y = cs.YW * fn_g(M);
-    var Z = cs.ZW * fn_g(N);
-    var r, g, b;
+    let M = (Ls + 16) / 116;
+    let L = M + as / 500;
+    let N = M - bs / 200;
+    let X = cs.XW * fn_g(L);
+    let Y = cs.YW * fn_g(M);
+    let Z = cs.ZW * fn_g(N);
+    let r, g, b;
     if (cs.ZW < 1) {
       r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
       g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
       b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
     } else {
       r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
       g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
       b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
     }
     dest[destOffset] = Math.sqrt(r) * 255;
     dest[destOffset + 1] = Math.sqrt(g) * 255;
     dest[destOffset + 2] = Math.sqrt(b) * 255;
   }
-  LabCS.prototype = {
-    getRgb: ColorSpace.prototype.getRgb,
+  class LabCS extends ColorSpace {
+    constructor(whitePoint, blackPoint, range) {
+      super('Lab', 3);
+      if (!whitePoint) {
+        throw new _util.FormatError('WhitePoint missing - required for color space Lab');
+      }
+      blackPoint = blackPoint || [0, 0, 0];
+      range = range || [-100, 100, -100, 100];
+      this.XW = whitePoint[0];
+      this.YW = whitePoint[1];
+      this.ZW = whitePoint[2];
+      this.amin = range[0];
+      this.amax = range[1];
+      this.bmin = range[2];
+      this.bmax = range[3];
+      this.XB = blackPoint[0];
+      this.YB = blackPoint[1];
+      this.ZB = blackPoint[2];
+      if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
+        throw new _util.FormatError('Invalid WhitePoint components, no fallback available');
+      }
+      if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
+        (0, _util.info)('Invalid BlackPoint, falling back to default');
+        this.XB = this.YB = this.ZB = 0;
+      }
+      if (this.amin > this.amax || this.bmin > this.bmax) {
+        (0, _util.info)('Invalid Range, falling back to defaults');
+        this.amin = -100;
+        this.amax = 100;
+        this.bmin = -100;
+        this.bmax = 100;
+      }
+    }
     getRgbItem(src, srcOffset, dest, destOffset) {
       convertToRgb(this, src, srcOffset, false, dest, destOffset);
-    },
+    }
     getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
-      var maxVal = (1 << bits) - 1;
-      for (var i = 0; i < count; i++) {
+      let maxVal = (1 << bits) - 1;
+      for (let i = 0; i < count; i++) {
         convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
         srcOffset += 3;
         destOffset += 3 + alpha01;
       }
-    },
+    }
     getOutputLength(inputLength, alpha01) {
       return inputLength * (3 + alpha01) / 3 | 0;
-    },
-    isPassthrough: ColorSpace.prototype.isPassthrough,
-    fillRgb: ColorSpace.prototype.fillRgb,
+    }
     isDefaultDecode(decodeMap) {
       return true;
-    },
-    usesZeroToOneRange: false
-  };
+    }
+    get usesZeroToOneRange() {
+      return (0, _util.shadow)(this, 'usesZeroToOneRange', false);
+    }
+  }
   return LabCS;
 }();
 exports.ColorSpace = ColorSpace;
 
 /***/ }),
 /* 26 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
--- a/browser/extensions/pdfjs/content/web/viewer.js
+++ b/browser/extensions/pdfjs/content/web/viewer.js
@@ -1,13 +1,13 @@
 /**
  * @licstart The following is the entire license notice for the
  * Javascript code in this page
  *
- * Copyright 2017 Mozilla Foundation
+ * Copyright 2018 Mozilla Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
@@ -391,17 +391,17 @@ let PDFViewerApplication = {
         _app_options.AppOptions.set('externalLinkTarget', _pdfjsLib.LinkTarget.TOP);
       }
       return this._initializeViewerComponents();
     }).then(() => {
       this.bindEvents();
       this.bindWindowEvents();
       let appContainer = appConfig.appContainer || document.documentElement;
       this.l10n.translate(appContainer).then(() => {
-        this.eventBus.dispatch('localized');
+        this.eventBus.dispatch('localized', { source: this });
       });
       this.initialized = true;
     });
   },
   _readPreferences() {
     const OVERRIDES = {
       disableFontFace: true,
       disableRange: true,
@@ -475,17 +475,18 @@ let PDFViewerApplication = {
     return this.l10n.getDirection().then(dir => {
       document.getElementsByTagName('html')[0].dir = dir;
     });
   },
   _initializeViewerComponents() {
     let { appConfig } = this;
     return new Promise((resolve, reject) => {
       this.overlayManager = new _overlay_manager.OverlayManager();
-      let eventBus = appConfig.eventBus || (0, _dom_events.getGlobalEventBus)();
+      const dispatchToDOM = _app_options.AppOptions.get('eventBusDispatchToDOM');
+      let eventBus = appConfig.eventBus || (0, _dom_events.getGlobalEventBus)(dispatchToDOM);
       this.eventBus = eventBus;
       let pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
       pdfRenderingQueue.onIdle = this.cleanup.bind(this);
       this.pdfRenderingQueue = pdfRenderingQueue;
       let pdfLinkService = new _pdf_link_service.PDFLinkService({
         eventBus,
         externalLinkTarget: _app_options.AppOptions.get('externalLinkTarget'),
         externalLinkRel: _app_options.AppOptions.get('externalLinkRel')
@@ -880,16 +881,17 @@ let PDFViewerApplication = {
     }
   },
   load(pdfDocument) {
     this.pdfDocument = pdfDocument;
     pdfDocument.getDownloadInfo().then(() => {
       this.downloadComplete = true;
       this.loadingBar.hide();
       firstPagePromise.then(() => {
+        this.eventBus.dispatch('documentloaded', { source: this });
         this.eventBus.dispatch('documentload', { source: this });
       });
     });
     let pageModePromise = pdfDocument.getPageMode().catch(function () {});
     this.toolbar.setPagesCount(pdfDocument.numPages, false);
     this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
     const store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint);
     let baseDocumentUrl;
@@ -955,16 +957,17 @@ let PDFViewerApplication = {
         initialParams.bookmark = this.initialBookmark;
         initialParams.hash = hash;
         this.setInitialView(hash, {
           rotation,
           sidebarView,
           scrollMode,
           spreadMode
         });
+        this.eventBus.dispatch('documentinit', { source: this });
         if (!this.isViewerEmbedded) {
           pdfViewer.focus();
         }
         return Promise.race([pagesPromise, new Promise(resolve => {
           setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
         })]);
       }).then(() => {
         if (!initialParams.bookmark && !initialParams.hash) {
@@ -1214,23 +1217,26 @@ let PDFViewerApplication = {
     eventBus.on('findfromurlhash', webViewerFindFromUrlHash);
   },
   bindWindowEvents() {
     let { eventBus, _boundEvents } = this;
     _boundEvents.windowResize = () => {
       eventBus.dispatch('resize', { source: window });
     };
     _boundEvents.windowHashChange = () => {
-      eventBus.dispatch('hashchange', { hash: document.location.hash.substring(1) });
+      eventBus.dispatch('hashchange', {
+        source: window,
+        hash: document.location.hash.substring(1)
+      });
     };
     _boundEvents.windowBeforePrint = () => {
-      eventBus.dispatch('beforeprint');
+      eventBus.dispatch('beforeprint', { source: window });
     };
     _boundEvents.windowAfterPrint = () => {
-      eventBus.dispatch('afterprint');
+      eventBus.dispatch('afterprint', { source: window });
     };
     window.addEventListener('wheel', webViewerWheel);
     window.addEventListener('click', webViewerClick);
     window.addEventListener('keydown', webViewerKeyDown);
     window.addEventListener('resize', _boundEvents.windowResize);
     window.addEventListener('hashchange', _boundEvents.windowHashChange);
     window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);
     window.addEventListener('afterprint', _boundEvents.windowAfterPrint);
@@ -2279,18 +2285,21 @@ function waitOnEventOrTimeout({ target, 
     const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
     let timeout = setTimeout(timeoutHandler, delay);
   });
 }
 let animationStarted = new Promise(function (resolve) {
   window.requestAnimationFrame(resolve);
 });
 class EventBus {
-  constructor() {
+  constructor({
+    dispatchToDOM = false
+  } = {}) {
     this._listeners = Object.create(null);
+    this._dispatchToDOM = dispatchToDOM === true;
   }
   on(eventName, listener) {
     let eventListeners = this._listeners[eventName];
     if (!eventListeners) {
       eventListeners = [];
       this._listeners[eventName] = eventListeners;
     }
     eventListeners.push(listener);
@@ -2301,22 +2310,50 @@ class EventBus {
     if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
       return;
     }
     eventListeners.splice(i, 1);
   }
   dispatch(eventName) {
     let eventListeners = this._listeners[eventName];
     if (!eventListeners || eventListeners.length === 0) {
+      if (this._dispatchToDOM) {
+        this._dispatchDOMEvent(eventName);
+      }
       return;
     }
     let args = Array.prototype.slice.call(arguments, 1);
     eventListeners.slice(0).forEach(function (listener) {
       listener.apply(null, args);
     });
+    if (this._dispatchToDOM) {
+      this._dispatchDOMEvent(eventName, args);
+    }
+  }
+  _dispatchDOMEvent(eventName, args = null) {
+    if (!this._dispatchToDOM) {
+      return;
+    }
+    const details = Object.create(null);
+    if (args && args.length > 0) {
+      const obj = args[0];
+      for (let key in obj) {
+        const value = obj[key];
+        if (key === 'source') {
+          if (value === window || value === document) {
+            return;
+          }
+          continue;
+        }
+        details[key] = value;
+      }
+    }
+    const event = document.createEvent('CustomEvent');
+    event.initCustomEvent(eventName, true, true, details);
+    document.dispatchEvent(event);
   }
 }
 function clamp(v, min, max) {
   return Math.min(Math.max(v, min), max);
 }
 class ProgressBar {
   constructor(id, { height, width, units } = {}) {
     this.visible = true;
@@ -3136,16 +3173,20 @@ const defaultOptions = {
   enablePrintAutoRotate: {
     value: false,
     kind: OptionKind.VIEWER
   },
   enableWebGL: {
     value: false,
     kind: OptionKind.VIEWER
   },
+  eventBusDispatchToDOM: {
+    value: false,
+    kind: OptionKind.VIEWER
+  },
   externalLinkRel: {
     value: 'noopener noreferrer nofollow',
     kind: OptionKind.VIEWER
   },
   externalLinkTarget: {
     value: 0,
     kind: OptionKind.VIEWER
   },
@@ -3403,22 +3444,23 @@ function attachDOMEventsToEventBus(event
   });
   eventBus.on('outlineloaded', function (evt) {
     let event = document.createEvent('CustomEvent');
     event.initCustomEvent('outlineloaded', true, true, { outlineCount: evt.outlineCount });
     evt.source.container.dispatchEvent(event);
   });
 }
 let globalEventBus = null;
-function getGlobalEventBus() {
-  if (globalEventBus) {
-    return globalEventBus;
-  }
-  globalEventBus = new _ui_utils.EventBus();
-  attachDOMEventsToEventBus(globalEventBus);
+function getGlobalEventBus(dispatchToDOM = false) {
+  if (!globalEventBus) {
+    globalEventBus = new _ui_utils.EventBus({ dispatchToDOM });
+    if (!dispatchToDOM) {
+      attachDOMEventsToEventBus(globalEventBus);
+    }
+  }
   return globalEventBus;
 }
 exports.attachDOMEventsToEventBus = attachDOMEventsToEventBus;
 exports.getGlobalEventBus = getGlobalEventBus;
 
 /***/ }),
 /* 11 */
 /***/ (function(module, exports, __webpack_require__) {
@@ -5387,29 +5429,29 @@ class PDFPresentationMode {
     this.args = null;
     this.contextMenuOpen = false;
     this.mouseScrollTimeStamp = 0;
     this.mouseScrollDelta = 0;
     this.touchSwipeState = null;
     if (contextMenuItems) {
       contextMenuItems.contextFirstPage.addEventListener('click', () => {
         this.contextMenuOpen = false;
-        this.eventBus.dispatch('firstpage');
+        this.eventBus.dispatch('firstpage', { source: this });
       });
       contextMenuItems.contextLastPage.addEventListener('click', () => {
         this.contextMenuOpen = false;
-        this.eventBus.dispatch('lastpage');
+        this.eventBus.dispatch('lastpage', { source: this });
       });
       contextMenuItems.contextPageRotateCw.addEventListener('click', () => {
         this.contextMenuOpen = false;
-        this.eventBus.dispatch('rotatecw');
+        this.eventBus.dispatch('rotatecw', { source: this });
       });
       contextMenuItems.contextPageRotateCcw.addEventListener('click', () => {
         this.contextMenuOpen = false;
-        this.eventBus.dispatch('rotateccw');
+        this.eventBus.dispatch('rotateccw', { source: this });
       });
     }
   }
   request() {
     if (this.switchInProgress || this.active || !this.viewer.hasChildNodes()) {
       return false;
     }
     this._addFullscreenChangeListeners();
@@ -8452,26 +8494,26 @@ class Toolbar {
     this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
     this.pageScale = _ui_utils.DEFAULT_SCALE;
     this._updateUIState(true);
   }
   _bindListeners() {
     let { eventBus, items } = this;
     let self = this;
     items.previous.addEventListener('click', function () {
-      eventBus.dispatch('previouspage');
+      eventBus.dispatch('previouspage', { source: self });
     });
     items.next.addEventListener('click', function () {
-      eventBus.dispatch('nextpage');
+      eventBus.dispatch('nextpage', { source: self });
     });
     items.zoomIn.addEventListener('click', function () {
-      eventBus.dispatch('zoomin');
+      eventBus.dispatch('zoomin', { source: self });
     });
     items.zoomOut.addEventListener('click', function () {
-      eventBus.dispatch('zoomout');
+      eventBus.dispatch('zoomout', { source: self });
     });
     items.pageNumber.addEventListener('click', function () {
       this.select();
     });
     items.pageNumber.addEventListener('change', function () {
       eventBus.dispatch('pagenumberchanged', {
         source: self,
         value: this.value
@@ -8482,26 +8524,26 @@ class Toolbar {
         return;
       }
       eventBus.dispatch('scalechanged', {
         source: self,
         value: this.value
       });
     });
     items.presentationModeButton.addEventListener('click', function () {
-      eventBus.dispatch('presentationmode');
+      eventBus.dispatch('presentationmode', { source: self });
     });
     items.openFile.addEventListener('click', function () {
-      eventBus.dispatch('openfile');
+      eventBus.dispatch('openfile', { source: self });
     });
     items.print.addEventListener('click', function () {
-      eventBus.dispatch('print');
+      eventBus.dispatch('print', { source: self });
     });
     items.download.addEventListener('click', function () {
-      eventBus.dispatch('download');
+      eventBus.dispatch('download', { source: self });
     });
     items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
     eventBus.on('localized', () => {
       this._localized();
     });
   }
   _localized() {
     this._wasLocalized = true;
@@ -9029,16 +9071,17 @@ let defaultPreferences = null;
 function getDefaultPreferences() {
   if (!defaultPreferences) {
     defaultPreferences = Promise.resolve({
       "showPreviousViewOnLoad": true,
       "defaultZoomValue": "",
       "sidebarViewOnLoad": 0,
       "cursorToolOnLoad": 0,
       "enableWebGL": false,
+      "eventBusDispatchToDOM": false,
       "pdfBugEnabled": false,
       "disableRange": false,
       "disableStream": false,
       "disableAutoFetch": false,
       "disableFontFace": false,
       "textLayerMode": 1,
       "useOnlyCssZoom": false,
       "externalLinkTarget": 0,
--- a/browser/extensions/pdfjs/moz.yaml
+++ b/browser/extensions/pdfjs/moz.yaml
@@ -15,15 +15,15 @@ origin:
   description: Portable Document Format (PDF) viewer that is built with HTML5
 
   # Full URL for the package's homepage/etc
   # Usually different from repository url
   url: https://github.com/mozilla/pdf.js
 
   # Human-readable identifier for this version/release
   # Generally "version NNN", "tag SSS", "bookmark SSS"
-  release: version 2.0.775
+  release: version 2.0.815
 
   # The package's license, where possible using the mnemonic from
   # https://spdx.org/licenses/
   # Multiple licenses can be specified (as a YAML list)
   # A "LICENSE" file must exist containing the full license text
   license: Apache-2.0