Bug 1516969 - Update pdf.js to version 2.1.145. r=bdahl
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 31 Dec 2018 08:33:37 -0500
changeset 509285 275c43b8572c70306e56d30e1f4e3df2f1c7090f
parent 509284 79f02fb1a1afed2d5b4f116d3b09c5cd6d6cbc94
child 509286 83d06ab87e742c2eb63bce720741c0a222d20f36
child 509305 13c1ffa4ed2b21db98e2064d16c71ea5d6c874e9
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbdahl
bugs1516969
milestone66.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 1516969 - Update pdf.js to version 2.1.145. r=bdahl
browser/extensions/pdfjs/README.mozilla
browser/extensions/pdfjs/content/build/pdf.js
browser/extensions/pdfjs/content/build/pdf.worker.js
browser/extensions/pdfjs/content/web/viewer.css
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.1.132
+Current extension version is: 2.1.145
 
-Taken from upstream commit: d3868e1b
+Taken from upstream commit: d8f201ea
--- a/browser/extensions/pdfjs/content/build/pdf.js
+++ b/browser/extensions/pdfjs/content/build/pdf.js
@@ -118,18 +118,18 @@ return /******/ (function(modules) { // 
 /************************************************************************/
 /******/ ([
 /* 0 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-var pdfjsVersion = '2.1.132';
-var pdfjsBuild = 'd3868e1b';
+var pdfjsVersion = '2.1.145';
+var pdfjsBuild = 'd8f201ea';
 
 var pdfjsSharedUtil = __w_pdfjs_require__(1);
 
 var pdfjsDisplayAPI = __w_pdfjs_require__(7);
 
 var pdfjsDisplayTextLayer = __w_pdfjs_require__(19);
 
 var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(20);
@@ -230,17 +230,17 @@ Object.defineProperty(exports, "Readable
   }
 });
 Object.defineProperty(exports, "URL", {
   enumerable: true,
   get: function () {
     return _url_polyfill.URL;
   }
 });
-exports.createObjectURL = exports.FormatError = exports.XRefParseException = 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 = void 0;
+exports.createObjectURL = exports.FormatError = exports.XRefParseException = exports.XRefEntryException = 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 = void 0;
 
 __w_pdfjs_require__(2);
 
 var _streams_polyfill = __w_pdfjs_require__(4);
 
 var _url_polyfill = __w_pdfjs_require__(6);
 
 const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
@@ -690,16 +690,29 @@ var MissingDataException = function Miss
   MissingDataException.prototype = new Error();
   MissingDataException.prototype.name = 'MissingDataException';
   MissingDataException.constructor = MissingDataException;
   return MissingDataException;
 }();
 
 exports.MissingDataException = MissingDataException;
 
+const XRefEntryException = function XRefEntryExceptionClosure() {
+  function XRefEntryException(msg) {
+    this.message = msg;
+  }
+
+  XRefEntryException.prototype = new Error();
+  XRefEntryException.prototype.name = 'XRefEntryException';
+  XRefEntryException.constructor = XRefEntryException;
+  return XRefEntryException;
+}();
+
+exports.XRefEntryException = XRefEntryException;
+
 var XRefParseException = function XRefParseExceptionClosure() {
   function XRefParseException(msg) {
     this.message = msg;
   }
 
   XRefParseException.prototype = new Error();
   XRefParseException.prototype.name = 'XRefParseException';
   XRefParseException.constructor = XRefParseException;
@@ -5136,17 +5149,17 @@ function _fetchDocument(worker, source, 
 
   if (pdfDataRangeTransport) {
     source.length = pdfDataRangeTransport.length;
     source.initialData = pdfDataRangeTransport.initialData;
   }
 
   return worker.messageHandler.sendWithPromise('GetDocRequest', {
     docId,
-    apiVersion: '2.1.132',
+    apiVersion: '2.1.145',
     source: {
       data: source.data,
       url: source.url,
       password: source.password,
       disableAutoFetch: source.disableAutoFetch,
       rangeChunkSize: source.rangeChunkSize,
       length: source.length
     },
@@ -6867,19 +6880,19 @@ const InternalRenderTask = function Inte
       }
     }
 
   }
 
   return InternalRenderTask;
 }();
 
-const version = '2.1.132';
+const version = '2.1.145';
 exports.version = version;
-const build = 'd3868e1b';
+const build = 'd8f201ea';
 exports.build = build;
 
 /***/ }),
 /* 8 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
@@ -8779,21 +8792,20 @@ var CanvasGraphics = function CanvasGrap
 
       if (fontObj.isType3Font) {
         return;
       }
 
       var name = fontObj.loadedName || 'sans-serif';
       var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
       var italic = fontObj.italic ? 'italic' : 'normal';
-      var typeface = '"' + name + '", ' + fontObj.fallbackName;
+      var typeface = `"${name}", ${fontObj.fallbackName}`;
       var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
       this.current.fontSizeScale = size / browserFontSize;
-      var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
-      this.ctx.font = rule;
+      this.ctx.font = `${italic} ${bold} ${browserFontSize}px ${typeface}`;
     },
     setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
       this.current.textRenderingMode = mode;
     },
     setTextRise: function CanvasGraphics_setTextRise(rise) {
       this.current.textRise = rise;
     },
     moveText: function CanvasGraphics_moveText(x, y) {
@@ -12339,24 +12351,24 @@ var renderTextLayer = function renderTex
       }
 
       let width = this._layoutTextCtx.measureText(textDiv.textContent).width;
 
       let transform = '';
 
       if (textDivProperties.canvasWidth !== 0 && width > 0) {
         textDivProperties.scale = textDivProperties.canvasWidth / width;
-        transform = 'scaleX(' + textDivProperties.scale + ')';
+        transform = `scaleX(${textDivProperties.scale})`;
       }
 
       if (textDivProperties.angle !== 0) {
-        transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
-      }
-
-      if (transform !== '') {
+        transform = `rotate(${textDivProperties.angle}deg) ${transform}`;
+      }
+
+      if (transform.length > 0) {
         textDivProperties.originalTransform = transform;
         textDiv.style.transform = transform;
       }
 
       this._textDivProperties.set(textDiv, textDivProperties);
 
       textLayerFrag.appendChild(textDiv);
     },
--- a/browser/extensions/pdfjs/content/build/pdf.worker.js
+++ b/browser/extensions/pdfjs/content/build/pdf.worker.js
@@ -118,18 +118,18 @@ return /******/ (function(modules) { // 
 /************************************************************************/
 /******/ ([
 /* 0 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-var pdfjsVersion = '2.1.132';
-var pdfjsBuild = 'd3868e1b';
+var pdfjsVersion = '2.1.145';
+var pdfjsBuild = 'd8f201ea';
 
 var pdfjsCoreWorker = __w_pdfjs_require__(1);
 
 exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
 
 /***/ }),
 /* 1 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
@@ -370,17 +370,17 @@ var WorkerMessageHandler = {
   },
 
   createDocumentHandler(docParams, port) {
     var pdfManager;
     var terminated = false;
     var cancelXHRs = null;
     var WorkerTasks = [];
     let apiVersion = docParams.apiVersion;
-    let workerVersion = '2.1.132';
+    let workerVersion = '2.1.145';
 
     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';
@@ -398,38 +398,30 @@ var WorkerMessageHandler = {
     }
 
     function finishWorkerTask(task) {
       task.finish();
       var i = WorkerTasks.indexOf(task);
       WorkerTasks.splice(i, 1);
     }
 
-    function loadDocument(recoveryMode) {
-      var loadDocumentCapability = (0, _util.createPromiseCapability)();
-
-      var parseSuccess = function parseSuccess() {
-        Promise.all([pdfManager.ensureDoc('numPages'), pdfManager.ensureDoc('fingerprint')]).then(function ([numPages, fingerprint]) {
-          loadDocumentCapability.resolve({
-            numPages,
-            fingerprint
-          });
-        }, parseFailure);
-      };
-
-      var parseFailure = function parseFailure(e) {
-        loadDocumentCapability.reject(e);
-      };
-
-      pdfManager.ensureDoc('checkHeader', []).then(function () {
-        pdfManager.ensureDoc('parseStartXRef', []).then(function () {
-          pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
-        }, parseFailure);
-      }, parseFailure);
-      return loadDocumentCapability.promise;
+    async function loadDocument(recoveryMode) {
+      await pdfManager.ensureDoc('checkHeader');
+      await pdfManager.ensureDoc('parseStartXRef');
+      await pdfManager.ensureDoc('parse', [recoveryMode]);
+
+      if (!recoveryMode) {
+        await pdfManager.ensureDoc('checkFirstPage');
+      }
+
+      const [numPages, fingerprint] = await Promise.all([pdfManager.ensureDoc('numPages'), pdfManager.ensureDoc('fingerprint')]);
+      return {
+        numPages,
+        fingerprint
+      };
     }
 
     function getPdfManager(data, evaluatorOptions) {
       var pdfManagerCapability = (0, _util.createPromiseCapability)();
       var pdfManager;
       var source = data.source;
 
       if (source.data) {
@@ -875,17 +867,17 @@ Object.defineProperty(exports, "Readable
   }
 });
 Object.defineProperty(exports, "URL", {
   enumerable: true,
   get: function () {
     return _url_polyfill.URL;
   }
 });
-exports.createObjectURL = exports.FormatError = exports.XRefParseException = 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 = void 0;
+exports.createObjectURL = exports.FormatError = exports.XRefParseException = exports.XRefEntryException = 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 = void 0;
 
 __w_pdfjs_require__(3);
 
 var _streams_polyfill = __w_pdfjs_require__(5);
 
 var _url_polyfill = __w_pdfjs_require__(7);
 
 const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
@@ -1335,16 +1327,29 @@ var MissingDataException = function Miss
   MissingDataException.prototype = new Error();
   MissingDataException.prototype.name = 'MissingDataException';
   MissingDataException.constructor = MissingDataException;
   return MissingDataException;
 }();
 
 exports.MissingDataException = MissingDataException;
 
+const XRefEntryException = function XRefEntryExceptionClosure() {
+  function XRefEntryException(msg) {
+    this.message = msg;
+  }
+
+  XRefEntryException.prototype = new Error();
+  XRefEntryException.prototype.name = 'XRefEntryException';
+  XRefEntryException.constructor = XRefEntryException;
+  return XRefEntryException;
+}();
+
+exports.XRefEntryException = XRefEntryException;
+
 var XRefParseException = function XRefParseExceptionClosure() {
   function XRefParseException(msg) {
     this.message = msg;
   }
 
   XRefParseException.prototype = new Error();
   XRefParseException.prototype.name = 'XRefParseException';
   XRefParseException.constructor = XRefParseException;
@@ -6367,25 +6372,25 @@ var _crypto = __w_pdfjs_require__(24);
 var _parser = __w_pdfjs_require__(13);
 
 var _operator_list = __w_pdfjs_require__(27);
 
 var _evaluator = __w_pdfjs_require__(28);
 
 var _function = __w_pdfjs_require__(42);
 
-var Page = function PageClosure() {
-  var DEFAULT_USER_UNIT = 1.0;
-  var LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
-
-  function isAnnotationRenderable(annotation, intent) {
-    return intent === 'display' && annotation.viewable || intent === 'print' && annotation.printable;
-  }
-
-  function Page({
+const DEFAULT_USER_UNIT = 1.0;
+const LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
+
+function isAnnotationRenderable(annotation, intent) {
+  return intent === 'display' && annotation.viewable || intent === 'print' && annotation.printable;
+}
+
+class Page {
+  constructor({
     pdfManager,
     xref,
     pageIndex,
     pageDict,
     ref,
     fontCache,
     builtInCMapCache,
     pdfFunctionFactory
@@ -6395,626 +6400,628 @@ var Page = function PageClosure() {
     this.pageDict = pageDict;
     this.xref = xref;
     this.ref = ref;
     this.fontCache = fontCache;
     this.builtInCMapCache = builtInCMapCache;
     this.pdfFunctionFactory = pdfFunctionFactory;
     this.evaluatorOptions = pdfManager.evaluatorOptions;
     this.resourcesPromise = null;
-    var uniquePrefix = 'p' + this.pageIndex + '_';
-    var idCounters = {
+    const uniquePrefix = `p${this.pageIndex}_`;
+    const idCounters = {
       obj: 0
     };
     this.idFactory = {
       createObjId() {
         return uniquePrefix + ++idCounters.obj;
       }
 
     };
   }
 
-  Page.prototype = {
-    _getInheritableProperty(key, getArray = false) {
-      let value = (0, _util.getInheritableProperty)({
-        dict: this.pageDict,
-        key,
-        getArray,
-        stopWhenFound: false
-      });
-
-      if (!Array.isArray(value)) {
-        return value;
-      }
-
-      if (value.length === 1 || !(0, _primitives.isDict)(value[0])) {
-        return value[0];
-      }
-
-      return _primitives.Dict.merge(this.xref, value);
-    },
-
-    get content() {
-      return this.pageDict.get('Contents');
-    },
-
-    get resources() {
-      return (0, _util.shadow)(this, 'resources', this._getInheritableProperty('Resources') || _primitives.Dict.empty);
-    },
-
-    get mediaBox() {
-      var mediaBox = this._getInheritableProperty('MediaBox', true);
-
-      if (!Array.isArray(mediaBox) || mediaBox.length !== 4) {
-        return (0, _util.shadow)(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
-      }
-
-      return (0, _util.shadow)(this, 'mediaBox', mediaBox);
-    },
-
-    get cropBox() {
-      var cropBox = this._getInheritableProperty('CropBox', true);
-
-      if (!Array.isArray(cropBox) || cropBox.length !== 4) {
-        return (0, _util.shadow)(this, 'cropBox', this.mediaBox);
-      }
-
-      return (0, _util.shadow)(this, 'cropBox', cropBox);
-    },
-
-    get userUnit() {
-      var obj = this.pageDict.get('UserUnit');
-
-      if (!(0, _util.isNum)(obj) || obj <= 0) {
-        obj = DEFAULT_USER_UNIT;
-      }
-
-      return (0, _util.shadow)(this, 'userUnit', obj);
-    },
-
-    get view() {
-      var mediaBox = this.mediaBox,
+  _getInheritableProperty(key, getArray = false) {
+    const value = (0, _util.getInheritableProperty)({
+      dict: this.pageDict,
+      key,
+      getArray,
+      stopWhenFound: false
+    });
+
+    if (!Array.isArray(value)) {
+      return value;
+    }
+
+    if (value.length === 1 || !(0, _primitives.isDict)(value[0])) {
+      return value[0];
+    }
+
+    return _primitives.Dict.merge(this.xref, value);
+  }
+
+  get content() {
+    return this.pageDict.get('Contents');
+  }
+
+  get resources() {
+    return (0, _util.shadow)(this, 'resources', this._getInheritableProperty('Resources') || _primitives.Dict.empty);
+  }
+
+  get mediaBox() {
+    const mediaBox = this._getInheritableProperty('MediaBox', true);
+
+    if (!Array.isArray(mediaBox) || mediaBox.length !== 4) {
+      return (0, _util.shadow)(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
+    }
+
+    return (0, _util.shadow)(this, 'mediaBox', mediaBox);
+  }
+
+  get cropBox() {
+    const cropBox = this._getInheritableProperty('CropBox', true);
+
+    if (!Array.isArray(cropBox) || cropBox.length !== 4) {
+      return (0, _util.shadow)(this, 'cropBox', this.mediaBox);
+    }
+
+    return (0, _util.shadow)(this, 'cropBox', cropBox);
+  }
+
+  get userUnit() {
+    let obj = this.pageDict.get('UserUnit');
+
+    if (!(0, _util.isNum)(obj) || obj <= 0) {
+      obj = DEFAULT_USER_UNIT;
+    }
+
+    return (0, _util.shadow)(this, 'userUnit', obj);
+  }
+
+  get view() {
+    const mediaBox = this.mediaBox,
           cropBox = this.cropBox;
 
-      if (mediaBox === cropBox) {
-        return (0, _util.shadow)(this, 'view', mediaBox);
-      }
-
-      var intersection = _util.Util.intersect(cropBox, mediaBox);
-
-      return (0, _util.shadow)(this, 'view', intersection || mediaBox);
-    },
-
-    get rotate() {
-      var rotate = this._getInheritableProperty('Rotate') || 0;
-
-      if (rotate % 90 !== 0) {
-        rotate = 0;
-      } else if (rotate >= 360) {
-        rotate = rotate % 360;
-      } else if (rotate < 0) {
-        rotate = (rotate % 360 + 360) % 360;
-      }
-
-      return (0, _util.shadow)(this, 'rotate', rotate);
-    },
-
-    getContentStream: function Page_getContentStream() {
-      var content = this.content;
-      var stream;
-
-      if (Array.isArray(content)) {
-        var xref = this.xref;
-        var i,
-            n = content.length;
-        var streams = [];
-
-        for (i = 0; i < n; ++i) {
-          streams.push(xref.fetchIfRef(content[i]));
-        }
-
-        stream = new _stream.StreamsSequenceStream(streams);
-      } else if ((0, _primitives.isStream)(content)) {
-        stream = content;
-      } else {
-        stream = new _stream.NullStream();
-      }
-
-      return stream;
-    },
-    loadResources: function Page_loadResources(keys) {
-      if (!this.resourcesPromise) {
-        this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
-      }
-
-      return this.resourcesPromise.then(() => {
-        let objectLoader = new _obj.ObjectLoader(this.resources, keys, this.xref);
-        return objectLoader.load();
-      });
-    },
-
-    getOperatorList({
+    if (mediaBox === cropBox) {
+      return (0, _util.shadow)(this, 'view', mediaBox);
+    }
+
+    const intersection = _util.Util.intersect(cropBox, mediaBox);
+
+    return (0, _util.shadow)(this, 'view', intersection || mediaBox);
+  }
+
+  get rotate() {
+    let rotate = this._getInheritableProperty('Rotate') || 0;
+
+    if (rotate % 90 !== 0) {
+      rotate = 0;
+    } else if (rotate >= 360) {
+      rotate = rotate % 360;
+    } else if (rotate < 0) {
+      rotate = (rotate % 360 + 360) % 360;
+    }
+
+    return (0, _util.shadow)(this, 'rotate', rotate);
+  }
+
+  getContentStream() {
+    const content = this.content;
+    let stream;
+
+    if (Array.isArray(content)) {
+      const xref = this.xref;
+      const streams = [];
+
+      for (const stream of content) {
+        streams.push(xref.fetchIfRef(stream));
+      }
+
+      stream = new _stream.StreamsSequenceStream(streams);
+    } else if ((0, _primitives.isStream)(content)) {
+      stream = content;
+    } else {
+      stream = new _stream.NullStream();
+    }
+
+    return stream;
+  }
+
+  loadResources(keys) {
+    if (!this.resourcesPromise) {
+      this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
+    }
+
+    return this.resourcesPromise.then(() => {
+      const objectLoader = new _obj.ObjectLoader(this.resources, keys, this.xref);
+      return objectLoader.load();
+    });
+  }
+
+  getOperatorList({
+    handler,
+    task,
+    intent,
+    renderInteractiveForms
+  }) {
+    const contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
+    const resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']);
+    const partialEvaluator = new _evaluator.PartialEvaluator({
+      pdfManager: this.pdfManager,
+      xref: this.xref,
       handler,
-      task,
-      intent,
-      renderInteractiveForms
-    }) {
-      var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
-      var resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']);
-      var partialEvaluator = new _evaluator.PartialEvaluator({
+      pageIndex: this.pageIndex,
+      idFactory: this.idFactory,
+      fontCache: this.fontCache,
+      builtInCMapCache: this.builtInCMapCache,
+      options: this.evaluatorOptions,
+      pdfFunctionFactory: this.pdfFunctionFactory
+    });
+    const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
+    const pageListPromise = dataPromises.then(([contentStream]) => {
+      const opList = new _operator_list.OperatorList(intent, handler, this.pageIndex);
+      handler.send('StartRenderPage', {
+        transparency: partialEvaluator.hasBlendModes(this.resources),
+        pageIndex: this.pageIndex,
+        intent
+      });
+      return partialEvaluator.getOperatorList({
+        stream: contentStream,
+        task,
+        resources: this.resources,
+        operatorList: opList
+      }).then(function () {
+        return opList;
+      });
+    });
+    return Promise.all([pageListPromise, this._parsedAnnotations]).then(function ([pageOpList, annotations]) {
+      if (annotations.length === 0) {
+        pageOpList.flush(true);
+        return pageOpList;
+      }
+
+      const opListPromises = [];
+
+      for (const annotation of annotations) {
+        if (isAnnotationRenderable(annotation, intent)) {
+          opListPromises.push(annotation.getOperatorList(partialEvaluator, task, renderInteractiveForms));
+        }
+      }
+
+      return Promise.all(opListPromises).then(function (opLists) {
+        pageOpList.addOp(_util.OPS.beginAnnotations, []);
+
+        for (const opList of opLists) {
+          pageOpList.addOpList(opList);
+        }
+
+        pageOpList.addOp(_util.OPS.endAnnotations, []);
+        pageOpList.flush(true);
+        return pageOpList;
+      });
+    });
+  }
+
+  extractTextContent({
+    handler,
+    task,
+    normalizeWhitespace,
+    sink,
+    combineTextItems
+  }) {
+    const contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
+    const resourcesPromise = this.loadResources(['ExtGState', 'XObject', 'Font']);
+    const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
+    return dataPromises.then(([contentStream]) => {
+      const partialEvaluator = new _evaluator.PartialEvaluator({
         pdfManager: this.pdfManager,
         xref: this.xref,
         handler,
         pageIndex: this.pageIndex,
         idFactory: this.idFactory,
         fontCache: this.fontCache,
         builtInCMapCache: this.builtInCMapCache,
         options: this.evaluatorOptions,
         pdfFunctionFactory: this.pdfFunctionFactory
       });
-      var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
-      var pageListPromise = dataPromises.then(([contentStream]) => {
-        var opList = new _operator_list.OperatorList(intent, handler, this.pageIndex);
-        handler.send('StartRenderPage', {
-          transparency: partialEvaluator.hasBlendModes(this.resources),
-          pageIndex: this.pageIndex,
-          intent
-        });
-        return partialEvaluator.getOperatorList({
-          stream: contentStream,
-          task,
-          resources: this.resources,
-          operatorList: opList
-        }).then(function () {
-          return opList;
-        });
-      });
-      return Promise.all([pageListPromise, this._parsedAnnotations]).then(function ([pageOpList, annotations]) {
-        if (annotations.length === 0) {
-          pageOpList.flush(true);
-          return pageOpList;
-        }
-
-        var i,
-            ii,
-            opListPromises = [];
-
-        for (i = 0, ii = annotations.length; i < ii; i++) {
-          if (isAnnotationRenderable(annotations[i], intent)) {
-            opListPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderInteractiveForms));
-          }
-        }
-
-        return Promise.all(opListPromises).then(function (opLists) {
-          pageOpList.addOp(_util.OPS.beginAnnotations, []);
-
-          for (i = 0, ii = opLists.length; i < ii; i++) {
-            pageOpList.addOpList(opLists[i]);
-          }
-
-          pageOpList.addOp(_util.OPS.endAnnotations, []);
-          pageOpList.flush(true);
-          return pageOpList;
-        });
-      });
-    },
-
-    extractTextContent({
-      handler,
-      task,
-      normalizeWhitespace,
-      sink,
-      combineTextItems
-    }) {
-      var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
-      var resourcesPromise = this.loadResources(['ExtGState', 'XObject', 'Font']);
-      var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
-      return dataPromises.then(([contentStream]) => {
-        var partialEvaluator = new _evaluator.PartialEvaluator({
-          pdfManager: this.pdfManager,
-          xref: this.xref,
-          handler,
-          pageIndex: this.pageIndex,
-          idFactory: this.idFactory,
-          fontCache: this.fontCache,
-          builtInCMapCache: this.builtInCMapCache,
-          options: this.evaluatorOptions,
-          pdfFunctionFactory: this.pdfFunctionFactory
-        });
-        return partialEvaluator.getTextContent({
-          stream: contentStream,
-          task,
-          resources: this.resources,
-          normalizeWhitespace,
-          combineTextItems,
-          sink
-        });
-      });
-    },
-
-    getAnnotationsData(intent) {
-      return this._parsedAnnotations.then(function (annotations) {
-        let annotationsData = [];
-
-        for (let i = 0, ii = annotations.length; i < ii; i++) {
-          if (!intent || isAnnotationRenderable(annotations[i], intent)) {
-            annotationsData.push(annotations[i].data);
-          }
-        }
-
-        return annotationsData;
-      });
-    },
-
-    get annotations() {
-      return (0, _util.shadow)(this, 'annotations', this._getInheritableProperty('Annots') || []);
-    },
-
-    get _parsedAnnotations() {
-      const parsedAnnotations = this.pdfManager.ensure(this, 'annotations').then(() => {
-        const annotationRefs = this.annotations;
-        const annotationPromises = [];
-
-        for (let i = 0, ii = annotationRefs.length; i < ii; i++) {
-          annotationPromises.push(_annotation.AnnotationFactory.create(this.xref, annotationRefs[i], this.pdfManager, this.idFactory));
-        }
-
-        return Promise.all(annotationPromises).then(function (annotations) {
-          return annotations.filter(function isDefined(annotation) {
-            return !!annotation;
-          });
-        }, function (reason) {
-          (0, _util.warn)(`_parsedAnnotations: "${reason}".`);
-          return [];
-        });
-      });
-      return (0, _util.shadow)(this, '_parsedAnnotations', parsedAnnotations);
-    }
-
-  };
-  return Page;
-}();
+      return partialEvaluator.getTextContent({
+        stream: contentStream,
+        task,
+        resources: this.resources,
+        normalizeWhitespace,
+        combineTextItems,
+        sink
+      });
+    });
+  }
+
+  getAnnotationsData(intent) {
+    return this._parsedAnnotations.then(function (annotations) {
+      const annotationsData = [];
+
+      for (let i = 0, ii = annotations.length; i < ii; i++) {
+        if (!intent || isAnnotationRenderable(annotations[i], intent)) {
+          annotationsData.push(annotations[i].data);
+        }
+      }
+
+      return annotationsData;
+    });
+  }
+
+  get annotations() {
+    return (0, _util.shadow)(this, 'annotations', this._getInheritableProperty('Annots') || []);
+  }
+
+  get _parsedAnnotations() {
+    const parsedAnnotations = this.pdfManager.ensure(this, 'annotations').then(() => {
+      const annotationRefs = this.annotations;
+      const annotationPromises = [];
+
+      for (let i = 0, ii = annotationRefs.length; i < ii; i++) {
+        annotationPromises.push(_annotation.AnnotationFactory.create(this.xref, annotationRefs[i], this.pdfManager, this.idFactory));
+      }
+
+      return Promise.all(annotationPromises).then(function (annotations) {
+        return annotations.filter(function isDefined(annotation) {
+          return !!annotation;
+        });
+      }, function (reason) {
+        (0, _util.warn)(`_parsedAnnotations: "${reason}".`);
+        return [];
+      });
+    });
+    return (0, _util.shadow)(this, '_parsedAnnotations', parsedAnnotations);
+  }
+
+}
 
 exports.Page = Page;
-
-var PDFDocument = function PDFDocumentClosure() {
-  var FINGERPRINT_FIRST_BYTES = 1024;
-  var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
-
-  function PDFDocument(pdfManager, arg) {
-    var stream;
+const FINGERPRINT_FIRST_BYTES = 1024;
+const EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
+
+function find(stream, needle, limit, backwards) {
+  const pos = stream.pos;
+  const end = stream.end;
+
+  if (pos + limit > end) {
+    limit = end - pos;
+  }
+
+  const strBuf = [];
+
+  for (let i = 0; i < limit; ++i) {
+    strBuf.push(String.fromCharCode(stream.getByte()));
+  }
+
+  const str = strBuf.join('');
+  stream.pos = pos;
+  const index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
+
+  if (index === -1) {
+    return false;
+  }
+
+  stream.pos += index;
+  return true;
+}
+
+class PDFDocument {
+  constructor(pdfManager, arg) {
+    let stream;
 
     if ((0, _primitives.isStream)(arg)) {
       stream = arg;
     } else if ((0, _util.isArrayBuffer)(arg)) {
       stream = new _stream.Stream(arg);
     } else {
       throw new Error('PDFDocument: Unknown argument type');
     }
 
     if (stream.length <= 0) {
-      throw new Error('PDFDocument: stream must have data');
+      throw new Error('PDFDocument: Stream must have data');
     }
 
     this.pdfManager = pdfManager;
     this.stream = stream;
     this.xref = new _obj.XRef(stream, pdfManager);
-    let evaluatorOptions = pdfManager.evaluatorOptions;
     this.pdfFunctionFactory = new _function.PDFFunctionFactory({
       xref: this.xref,
-      isEvalSupported: evaluatorOptions.isEvalSupported
+      isEvalSupported: pdfManager.evaluatorOptions.isEvalSupported
     });
     this._pagePromises = [];
   }
 
-  function find(stream, needle, limit, backwards) {
-    var pos = stream.pos;
-    var end = stream.end;
-    var strBuf = [];
-
-    if (pos + limit > end) {
-      limit = end - pos;
-    }
-
-    for (var n = 0; n < limit; ++n) {
-      strBuf.push(String.fromCharCode(stream.getByte()));
-    }
-
-    var str = strBuf.join('');
-    stream.pos = pos;
-    var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
-
-    if (index === -1) {
-      return false;
-    }
-
-    stream.pos += index;
-    return true;
-  }
-
-  const DocumentInfoValidators = {
-    Title: _util.isString,
-    Author: _util.isString,
-    Subject: _util.isString,
-    Keywords: _util.isString,
-    Creator: _util.isString,
-    Producer: _util.isString,
-    CreationDate: _util.isString,
-    ModDate: _util.isString,
-    Trapped: _primitives.isName
-  };
-  PDFDocument.prototype = {
-    parse: function PDFDocument_parse(recoveryMode) {
-      this.setup(recoveryMode);
-      var version = this.catalog.catDict.get('Version');
-
-      if ((0, _primitives.isName)(version)) {
-        this.pdfFormatVersion = version.name;
-      }
-
-      try {
-        this.acroForm = this.catalog.catDict.get('AcroForm');
-
-        if (this.acroForm) {
-          this.xfa = this.acroForm.get('XFA');
-          var fields = this.acroForm.get('Fields');
-
-          if ((!fields || !Array.isArray(fields) || fields.length === 0) && !this.xfa) {
-            this.acroForm = null;
-          }
-        }
-      } catch (ex) {
-        if (ex instanceof _util.MissingDataException) {
-          throw ex;
-        }
-
-        (0, _util.info)('Something wrong with AcroForm entry');
-        this.acroForm = null;
-      }
-    },
-
-    get linearization() {
-      let linearization = null;
-
-      try {
-        linearization = _parser.Linearization.create(this.stream);
-      } catch (err) {
-        if (err instanceof _util.MissingDataException) {
-          throw err;
-        }
-
-        (0, _util.info)(err);
-      }
-
-      return (0, _util.shadow)(this, 'linearization', linearization);
-    },
-
-    get startXRef() {
-      var stream = this.stream;
-      var startXRef = 0;
-      var linearization = this.linearization;
-
-      if (linearization) {
-        stream.reset();
-
-        if (find(stream, 'endobj', 1024)) {
-          startXRef = stream.pos + 6;
-        }
-      } else {
-        var step = 1024;
-        var found = false,
-            pos = stream.end;
-
-        while (!found && pos > 0) {
-          pos -= step - 'startxref'.length;
-
-          if (pos < 0) {
-            pos = 0;
-          }
-
-          stream.pos = pos;
-          found = find(stream, 'startxref', step, true);
-        }
-
-        if (found) {
-          stream.skip(9);
-          var ch;
-
-          do {
-            ch = stream.getByte();
-          } while ((0, _util.isSpace)(ch));
-
-          var str = '';
-
-          while (ch >= 0x20 && ch <= 0x39) {
-            str += String.fromCharCode(ch);
-            ch = stream.getByte();
-          }
-
-          startXRef = parseInt(str, 10);
-
-          if (isNaN(startXRef)) {
-            startXRef = 0;
-          }
-        }
-      }
-
-      return (0, _util.shadow)(this, 'startXRef', startXRef);
-    },
-
-    checkHeader: function PDFDocument_checkHeader() {
-      var stream = this.stream;
+  parse(recoveryMode) {
+    this.setup(recoveryMode);
+    const version = this.catalog.catDict.get('Version');
+
+    if ((0, _primitives.isName)(version)) {
+      this.pdfFormatVersion = version.name;
+    }
+
+    try {
+      this.acroForm = this.catalog.catDict.get('AcroForm');
+
+      if (this.acroForm) {
+        this.xfa = this.acroForm.get('XFA');
+        const fields = this.acroForm.get('Fields');
+
+        if ((!fields || !Array.isArray(fields) || fields.length === 0) && !this.xfa) {
+          this.acroForm = null;
+        }
+      }
+    } catch (ex) {
+      if (ex instanceof _util.MissingDataException) {
+        throw ex;
+      }
+
+      (0, _util.info)('Cannot fetch AcroForm entry; assuming no AcroForms are present');
+      this.acroForm = null;
+    }
+  }
+
+  get linearization() {
+    let linearization = null;
+
+    try {
+      linearization = _parser.Linearization.create(this.stream);
+    } catch (err) {
+      if (err instanceof _util.MissingDataException) {
+        throw err;
+      }
+
+      (0, _util.info)(err);
+    }
+
+    return (0, _util.shadow)(this, 'linearization', linearization);
+  }
+
+  get startXRef() {
+    const stream = this.stream;
+    let startXRef = 0;
+
+    if (this.linearization) {
       stream.reset();
 
-      if (find(stream, '%PDF-', 1024)) {
-        stream.moveStart();
-        var MAX_VERSION_LENGTH = 12;
-        var version = '',
-            ch;
-
-        while ((ch = stream.getByte()) > 0x20) {
-          if (version.length >= MAX_VERSION_LENGTH) {
-            break;
-          }
-
-          version += String.fromCharCode(ch);
-        }
-
-        if (!this.pdfFormatVersion) {
-          this.pdfFormatVersion = version.substring(5);
-        }
-
-        return;
-      }
-    },
-    parseStartXRef: function PDFDocument_parseStartXRef() {
-      var startXRef = this.startXRef;
-      this.xref.setStartXRef(startXRef);
-    },
-    setup: function PDFDocument_setup(recoveryMode) {
-      this.xref.parse(recoveryMode);
-      this.catalog = new _obj.Catalog(this.pdfManager, this.xref);
-    },
-
-    get numPages() {
-      var linearization = this.linearization;
-      var num = linearization ? linearization.numPages : this.catalog.numPages;
-      return (0, _util.shadow)(this, 'numPages', num);
-    },
-
-    get documentInfo() {
-      const docInfo = {
-        PDFFormatVersion: this.pdfFormatVersion,
-        IsLinearized: !!this.linearization,
-        IsAcroFormPresent: !!this.acroForm,
-        IsXFAPresent: !!this.xfa
-      };
-      let infoDict;
-
-      try {
-        infoDict = this.xref.trailer.get('Info');
-      } catch (err) {
-        if (err instanceof _util.MissingDataException) {
-          throw err;
-        }
-
-        (0, _util.info)('The document information dictionary is invalid.');
-      }
-
-      if ((0, _primitives.isDict)(infoDict)) {
-        for (let key of infoDict.getKeys()) {
-          const value = infoDict.get(key);
-
-          if (DocumentInfoValidators[key]) {
-            if (DocumentInfoValidators[key](value)) {
-              docInfo[key] = typeof value !== 'string' ? value : (0, _util.stringToPDFString)(value);
-            } else {
-              (0, _util.info)(`Bad value in document info for "${key}".`);
-            }
-          } else if (typeof key === 'string') {
-            let customValue;
-
-            if ((0, _util.isString)(value)) {
-              customValue = (0, _util.stringToPDFString)(value);
-            } else if ((0, _primitives.isName)(value) || (0, _util.isNum)(value) || (0, _util.isBool)(value)) {
-              customValue = value;
-            } else {
-              (0, _util.info)(`Unsupported value in document info for (custom) "${key}".`);
-              continue;
-            }
-
-            if (!docInfo['Custom']) {
-              docInfo['Custom'] = Object.create(null);
-            }
-
-            docInfo['Custom'][key] = customValue;
-          }
-        }
-      }
-
-      return (0, _util.shadow)(this, 'documentInfo', docInfo);
-    },
-
-    get fingerprint() {
-      var xref = this.xref,
-          hash,
-          fileID = '';
-      var idArray = xref.trailer.get('ID');
-
-      if (Array.isArray(idArray) && idArray[0] && (0, _util.isString)(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
-        hash = (0, _util.stringToBytes)(idArray[0]);
-      } else {
-        if (this.stream.ensureRange) {
-          this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
-        }
-
-        hash = (0, _crypto.calculateMD5)(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
-      }
-
-      for (var i = 0, n = hash.length; i < n; i++) {
-        var hex = hash[i].toString(16);
-        fileID += hex.length === 1 ? '0' + hex : hex;
-      }
-
-      return (0, _util.shadow)(this, 'fingerprint', fileID);
-    },
-
-    _getLinearizationPage(pageIndex) {
-      const {
-        catalog,
-        linearization
-      } = this;
-      (0, _util.assert)(linearization && linearization.pageFirst === pageIndex);
-      const ref = new _primitives.Ref(linearization.objectNumberFirst, 0);
-      return this.xref.fetchAsync(ref).then(obj => {
-        if ((0, _primitives.isDict)(obj, 'Page') || (0, _primitives.isDict)(obj) && !obj.has('Type') && obj.has('Contents')) {
-          if (ref && !catalog.pageKidsCountCache.has(ref)) {
-            catalog.pageKidsCountCache.put(ref, 1);
-          }
-
-          return [obj, ref];
-        }
-
-        throw new _util.FormatError('The Linearization dictionary doesn\'t point ' + 'to a valid Page dictionary.');
-      }).catch(reason => {
-        (0, _util.info)(reason);
-        return catalog.getPageDict(pageIndex);
-      });
-    },
-
-    getPage(pageIndex) {
-      if (this._pagePromises[pageIndex] !== undefined) {
-        return this._pagePromises[pageIndex];
-      }
-
-      const {
-        catalog,
-        linearization
-      } = this;
-      const promise = linearization && linearization.pageFirst === pageIndex ? this._getLinearizationPage(pageIndex) : catalog.getPageDict(pageIndex);
-      return this._pagePromises[pageIndex] = promise.then(([pageDict, ref]) => {
-        return new Page({
-          pdfManager: this.pdfManager,
-          xref: this.xref,
-          pageIndex,
-          pageDict,
-          ref,
-          fontCache: catalog.fontCache,
-          builtInCMapCache: catalog.builtInCMapCache,
-          pdfFunctionFactory: this.pdfFunctionFactory
-        });
-      });
-    },
-
-    cleanup: function PDFDocument_cleanup() {
-      return this.catalog.cleanup();
-    }
-  };
-  return PDFDocument;
-}();
+      if (find(stream, 'endobj', 1024)) {
+        startXRef = stream.pos + 6;
+      }
+    } else {
+      const step = 1024;
+      const startXRefLength = 'startxref'.length;
+      let found = false,
+          pos = stream.end;
+
+      while (!found && pos > 0) {
+        pos -= step - startXRefLength;
+
+        if (pos < 0) {
+          pos = 0;
+        }
+
+        stream.pos = pos;
+        found = find(stream, 'startxref', step, true);
+      }
+
+      if (found) {
+        stream.skip(9);
+        let ch;
+
+        do {
+          ch = stream.getByte();
+        } while ((0, _util.isSpace)(ch));
+
+        let str = '';
+
+        while (ch >= 0x20 && ch <= 0x39) {
+          str += String.fromCharCode(ch);
+          ch = stream.getByte();
+        }
+
+        startXRef = parseInt(str, 10);
+
+        if (isNaN(startXRef)) {
+          startXRef = 0;
+        }
+      }
+    }
+
+    return (0, _util.shadow)(this, 'startXRef', startXRef);
+  }
+
+  checkHeader() {
+    const stream = this.stream;
+    stream.reset();
+
+    if (!find(stream, '%PDF-', 1024)) {
+      return;
+    }
+
+    stream.moveStart();
+    const MAX_PDF_VERSION_LENGTH = 12;
+    let version = '',
+        ch;
+
+    while ((ch = stream.getByte()) > 0x20) {
+      if (version.length >= MAX_PDF_VERSION_LENGTH) {
+        break;
+      }
+
+      version += String.fromCharCode(ch);
+    }
+
+    if (!this.pdfFormatVersion) {
+      this.pdfFormatVersion = version.substring(5);
+    }
+  }
+
+  parseStartXRef() {
+    this.xref.setStartXRef(this.startXRef);
+  }
+
+  setup(recoveryMode) {
+    this.xref.parse(recoveryMode);
+    this.catalog = new _obj.Catalog(this.pdfManager, this.xref);
+  }
+
+  get numPages() {
+    const linearization = this.linearization;
+    const num = linearization ? linearization.numPages : this.catalog.numPages;
+    return (0, _util.shadow)(this, 'numPages', num);
+  }
+
+  get documentInfo() {
+    const DocumentInfoValidators = {
+      Title: _util.isString,
+      Author: _util.isString,
+      Subject: _util.isString,
+      Keywords: _util.isString,
+      Creator: _util.isString,
+      Producer: _util.isString,
+      CreationDate: _util.isString,
+      ModDate: _util.isString,
+      Trapped: _primitives.isName
+    };
+    const docInfo = {
+      PDFFormatVersion: this.pdfFormatVersion,
+      IsLinearized: !!this.linearization,
+      IsAcroFormPresent: !!this.acroForm,
+      IsXFAPresent: !!this.xfa
+    };
+    let infoDict;
+
+    try {
+      infoDict = this.xref.trailer.get('Info');
+    } catch (err) {
+      if (err instanceof _util.MissingDataException) {
+        throw err;
+      }
+
+      (0, _util.info)('The document information dictionary is invalid.');
+    }
+
+    if ((0, _primitives.isDict)(infoDict)) {
+      for (const key of infoDict.getKeys()) {
+        const value = infoDict.get(key);
+
+        if (DocumentInfoValidators[key]) {
+          if (DocumentInfoValidators[key](value)) {
+            docInfo[key] = typeof value !== 'string' ? value : (0, _util.stringToPDFString)(value);
+          } else {
+            (0, _util.info)(`Bad value in document info for "${key}".`);
+          }
+        } else if (typeof key === 'string') {
+          let customValue;
+
+          if ((0, _util.isString)(value)) {
+            customValue = (0, _util.stringToPDFString)(value);
+          } else if ((0, _primitives.isName)(value) || (0, _util.isNum)(value) || (0, _util.isBool)(value)) {
+            customValue = value;
+          } else {
+            (0, _util.info)(`Unsupported value in document info for (custom) "${key}".`);
+            continue;
+          }
+
+          if (!docInfo['Custom']) {
+            docInfo['Custom'] = Object.create(null);
+          }
+
+          docInfo['Custom'][key] = customValue;
+        }
+      }
+    }
+
+    return (0, _util.shadow)(this, 'documentInfo', docInfo);
+  }
+
+  get fingerprint() {
+    let hash;
+    const idArray = this.xref.trailer.get('ID');
+
+    if (Array.isArray(idArray) && idArray[0] && (0, _util.isString)(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
+      hash = (0, _util.stringToBytes)(idArray[0]);
+    } else {
+      if (this.stream.ensureRange) {
+        this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
+      }
+
+      hash = (0, _crypto.calculateMD5)(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
+    }
+
+    let fingerprint = '';
+
+    for (const hashPart of hash) {
+      const hex = hashPart.toString(16);
+      fingerprint += hex.length === 1 ? '0' + hex : hex;
+    }
+
+    return (0, _util.shadow)(this, 'fingerprint', fingerprint);
+  }
+
+  _getLinearizationPage(pageIndex) {
+    const {
+      catalog,
+      linearization
+    } = this;
+    (0, _util.assert)(linearization && linearization.pageFirst === pageIndex);
+    const ref = new _primitives.Ref(linearization.objectNumberFirst, 0);
+    return this.xref.fetchAsync(ref).then(obj => {
+      if ((0, _primitives.isDict)(obj, 'Page') || (0, _primitives.isDict)(obj) && !obj.has('Type') && obj.has('Contents')) {
+        if (ref && !catalog.pageKidsCountCache.has(ref)) {
+          catalog.pageKidsCountCache.put(ref, 1);
+        }
+
+        return [obj, ref];
+      }
+
+      throw new _util.FormatError('The Linearization dictionary doesn\'t point ' + 'to a valid Page dictionary.');
+    }).catch(reason => {
+      (0, _util.info)(reason);
+      return catalog.getPageDict(pageIndex);
+    });
+  }
+
+  getPage(pageIndex) {
+    if (this._pagePromises[pageIndex] !== undefined) {
+      return this._pagePromises[pageIndex];
+    }
+
+    const {
+      catalog,
+      linearization
+    } = this;
+    const promise = linearization && linearization.pageFirst === pageIndex ? this._getLinearizationPage(pageIndex) : catalog.getPageDict(pageIndex);
+    return this._pagePromises[pageIndex] = promise.then(([pageDict, ref]) => {
+      return new Page({
+        pdfManager: this.pdfManager,
+        xref: this.xref,
+        pageIndex,
+        pageDict,
+        ref,
+        fontCache: catalog.fontCache,
+        builtInCMapCache: catalog.builtInCMapCache,
+        pdfFunctionFactory: this.pdfFunctionFactory
+      });
+    });
+  }
+
+  checkFirstPage() {
+    return this.getPage(0).catch(reason => {
+      if (reason instanceof _util.XRefEntryException) {
+        this._pagePromises.length = 0;
+        this.cleanup();
+        throw new _util.XRefParseException();
+      }
+    });
+  }
+
+  cleanup() {
+    return this.catalog.cleanup();
+  }
+
+}
 
 exports.PDFDocument = PDFDocument;
 
 /***/ }),
 /* 11 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
@@ -8498,33 +8505,34 @@ var XRef = function XRefClosure() {
 
       if (xrefEntry === null) {
         return this.cache[num] = null;
       }
 
       if (xrefEntry.uncompressed) {
         xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
       } else {
-        xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
+        xrefEntry = this.fetchCompressed(ref, xrefEntry, suppressEncryption);
       }
 
       if ((0, _primitives.isDict)(xrefEntry)) {
         xrefEntry.objId = ref.toString();
       } else if ((0, _primitives.isStream)(xrefEntry)) {
         xrefEntry.dict.objId = ref.toString();
       }
 
       return xrefEntry;
     },
-    fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
+
+    fetchUncompressed(ref, xrefEntry, suppressEncryption = false) {
       var gen = ref.gen;
       var num = ref.num;
 
       if (xrefEntry.gen !== gen) {
-        throw new _util.FormatError('inconsistent generation in XRef');
+        throw new _util.XRefEntryException(`Inconsistent generation in XRef: ${ref}`);
       }
 
       var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
       var parser = new _parser.Parser(new _parser.Lexer(stream), true, this);
       var obj1 = parser.getObj();
       var obj2 = parser.getObj();
       var obj3 = parser.getObj();
 
@@ -8532,44 +8540,45 @@ var XRef = function XRefClosure() {
         obj1 = parseInt(obj1, 10);
       }
 
       if (!Number.isInteger(obj2)) {
         obj2 = parseInt(obj2, 10);
       }
 
       if (obj1 !== num || obj2 !== gen || !(0, _primitives.isCmd)(obj3)) {
-        throw new _util.FormatError('bad XRef entry');
+        throw new _util.XRefEntryException(`Bad (uncompressed) XRef entry: ${ref}`);
       }
 
       if (obj3.cmd !== 'obj') {
         if (obj3.cmd.indexOf('obj') === 0) {
           num = parseInt(obj3.cmd.substring(3), 10);
 
           if (!Number.isNaN(num)) {
             return num;
           }
         }
 
-        throw new _util.FormatError('bad XRef entry');
+        throw new _util.XRefEntryException(`Bad (uncompressed) XRef entry: ${ref}`);
       }
 
       if (this.encrypt && !suppressEncryption) {
         xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
       } else {
         xrefEntry = parser.getObj();
       }
 
       if (!(0, _primitives.isStream)(xrefEntry)) {
         this.cache[num] = xrefEntry;
       }
 
       return xrefEntry;
     },
-    fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
+
+    fetchCompressed(ref, xrefEntry, suppressEncryption = false) {
       var tableOffset = xrefEntry.offset;
       var stream = this.fetch(new _primitives.Ref(tableOffset, 0));
 
       if (!(0, _primitives.isStream)(stream)) {
         throw new _util.FormatError('bad ObjStm stream');
       }
 
       var first = stream.dict.get('First');
@@ -8614,17 +8623,17 @@ var XRef = function XRefClosure() {
         if (entry && entry.offset === tableOffset && entry.gen === i) {
           this.cache[num] = entries[i];
         }
       }
 
       xrefEntry = entries[xrefEntry.gen];
 
       if (xrefEntry === undefined) {
-        throw new _util.FormatError('bad XRef entry for compressed object');
+        throw new _util.XRefEntryException(`Bad (compressed) XRef entry: ${ref}`);
       }
 
       return xrefEntry;
     },
 
     async fetchIfRefAsync(obj, suppressEncryption) {
       if (!(0, _primitives.isRef)(obj)) {
         return obj;
@@ -9235,23 +9244,21 @@ exports.Dict = Dict;
 var Ref = function RefClosure() {
   function Ref(num, gen) {
     this.num = num;
     this.gen = gen;
   }
 
   Ref.prototype = {
     toString: function Ref_toString() {
-      var str = this.num + 'R';
-
       if (this.gen !== 0) {
-        str += this.gen;
-      }
-
-      return str;
+        return `${this.num}R${this.gen}`;
+      }
+
+      return `${this.num}R`;
     }
   };
   return Ref;
 }();
 
 exports.Ref = Ref;
 
 var RefSet = function RefSetClosure() {
@@ -21972,23 +21979,27 @@ class AnnotationBorderStyle {
     this.width = 1;
     this.style = _util.AnnotationBorderStyleType.SOLID;
     this.dashArray = [3];
     this.horizontalCornerRadius = 0;
     this.verticalCornerRadius = 0;
   }
 
   setWidth(width) {
+    if ((0, _primitives.isName)(width)) {
+      width = parseFloat(width.name);
+    }
+
     if (Number.isInteger(width)) {
       this.width = width;
     }
   }
 
   setStyle(style) {
-    if (!style) {
+    if (!(0, _primitives.isName)(style)) {
       return;
     }
 
     switch (style.name) {
       case 'S':
         this.style = _util.AnnotationBorderStyleType.SOLID;
         break;
 
--- a/browser/extensions/pdfjs/content/web/viewer.css
+++ b/browser/extensions/pdfjs/content/web/viewer.css
@@ -51,16 +51,18 @@
 .textLayer .highlight.middle {
   border-radius: 0px;
 }
 
 .textLayer .highlight.selected {
   background-color: rgb(0, 100, 0);
 }
 
+.textLayer ::-moz-selection { background: rgb(0,0,255); }
+
 .textLayer ::selection { background: rgb(0,0,255); }
 
 .textLayer .endOfContent {
   display: block;
   position: absolute;
   left: 0px;
   top: 100%;
   right: 0px;
@@ -1670,16 +1672,17 @@ html[dir='rtl'] .outlineItemToggler::bef
   color: hsla(0,0%,100%,.8);
   font-style: italic;
   cursor: default;
 }
 
 /* TODO: file FF bug to support ::-moz-selection:window-inactive
    so we can override the opaque grey background when the window is inactive;
    see https://bugzilla.mozilla.org/show_bug.cgi?id=706209 */
+::-moz-selection { background: rgba(0,0,255,0.3); }
 ::selection { background: rgba(0,0,255,0.3); }
 
 #errorWrapper {
   background: none repeat scroll 0 0 #FF5555;
   color: white;
   left: 0;
   position: absolute;
   right: 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.1.132
+  release: version 2.1.145
 
   # 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