Merge inbound to mozilla-central r=merge a=merge
authorCiure Andrei <aciure@mozilla.com>
Fri, 17 Nov 2017 11:59:03 +0200
changeset 444064 a77c628829b389ed6ac608eadc88b09eb5115bef
parent 443995 249a8177ad915734b83c357d49213e26d889b377 (current diff)
parent 444063 144f04d80cf1a412012fc94c2d6d7d2c3f5d70b6 (diff)
child 444065 010374bce60670cf1348150fe493d0193318d4f6
child 444104 5ded2b81bed157d30d5f0ffd28b4bb80f298dcd1
child 444196 f8d4a96dd4783f9f9764366e592e2f1bb9330892
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge, merge
milestone59.0a1
first release with
nightly linux32
a77c628829b3 / 59.0a1 / 20171117100127 / files
nightly linux64
a77c628829b3 / 59.0a1 / 20171117100127 / files
nightly mac
a77c628829b3 / 59.0a1 / 20171117100127 / files
nightly win32
a77c628829b3 / 59.0a1 / 20171117100127 / files
nightly win64
a77c628829b3 / 59.0a1 / 20171117100127 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge inbound to mozilla-central r=merge a=merge
build/moz.configure/warnings.configure
dom/base/CustomElementRegistry.cpp
dom/base/CustomElementRegistry.h
dom/base/Element.cpp
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
layout/generic/crashtests/crashtests.list
layout/generic/nsFrame.cpp
layout/painting/nsDisplayList.cpp
layout/painting/nsDisplayList.h
testing/web-platform/meta/custom-elements/reactions/HTMLOptionElement.html.ini
testing/web-platform/meta/custom-elements/upgrading.html.ini
--- a/accessible/windows/msaa/AccessibleWrap.cpp
+++ b/accessible/windows/msaa/AccessibleWrap.cpp
@@ -1540,17 +1540,17 @@ AccessibleWrap::GetIAccessibleFor(const 
   }
 
   return nullptr;
 }
 
 already_AddRefed<IAccessible>
 AccessibleWrap::GetRemoteIAccessibleFor(const VARIANT& aVarChild)
 {
-  DocAccessible* doc = Document();
+  a11y::RootAccessible* root = RootAccessible();
   const nsTArray<DocAccessibleParent*>* remoteDocs =
     DocManager::TopLevelRemoteDocs();
   if (!remoteDocs) {
     return nullptr;
   }
 
   RefPtr<IAccessible> result;
 
@@ -1565,17 +1565,17 @@ AccessibleWrap::GetRemoteIAccessibleFor(
       continue;
     }
 
     Accessible* outerDoc = remoteDoc->OuterDocOfRemoteBrowser();
     if (!outerDoc) {
       continue;
     }
 
-    if (outerDoc->Document() != doc) {
+    if (outerDoc->RootAccessible() != root) {
       continue;
     }
 
     RefPtr<IDispatch> disp =
       GetProxiedAccessibleInSubtree(remoteDoc, aVarChild);
     if (!disp) {
       continue;
     }
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1037,17 +1037,21 @@ pref("dom.ipc.plugins.sandbox-level.flas
 #endif
 
 #if defined(MOZ_CONTENT_SANDBOX)
 // This controls the strength of the Windows content process sandbox for testing
 // purposes. This will require a restart.
 // On windows these levels are:
 // See - security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
 // SetSecurityLevelForContentProcess() for what the different settings mean.
+#if defined(NIGHTLY_BUILD)
+pref("security.sandbox.content.level", 5);
+#else
 pref("security.sandbox.content.level", 4);
+#endif
 
 // This controls the depth of stack trace that is logged when Windows sandbox
 // logging is turned on.  This is only currently available for the content
 // process because the only other sandbox (for GMP) has too strict a policy to
 // allow stack tracing.  This does not require a restart to take effect.
 pref("security.sandbox.windows.log.stackTraceDepth", 0);
 #endif
 
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -1148,24 +1148,21 @@ nsContextMenu.prototype = {
     function timerCallback() {}
     timerCallback.prototype = {
       notify: function sLA_timer_notify(aTimer) {
         channel.cancel(NS_ERROR_SAVE_LINK_AS_TIMEOUT);
       }
     };
 
     // setting up a new channel for 'right click - save link as ...'
-    // ideally we should use:
-    // * doc            - as the loadingNode, and/or
-    // * this.principal - as the loadingPrincipal
-    // for now lets use systemPrincipal to bypass mixedContentBlocker
-    // checks after redirects, see bug: 1136055
     var channel = NetUtil.newChannel({
                     uri: makeURI(linkURL),
-                    loadUsingSystemPrincipal: true
+                    loadingPrincipal: this.principal,
+                    contentPolicyType: Ci.nsIContentPolicy.TYPE_SAVEAS_DOWNLOAD,
+                    securityFlags: Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS,
                   });
 
     if (linkDownload)
       channel.contentDispositionFilename = linkDownload;
     if (channel instanceof Ci.nsIPrivateBrowsingChannel) {
       let docIsPrivate = PrivateBrowsingUtils.isBrowserPrivate(gBrowser.selectedBrowser);
       channel.setPrivate(docIsPrivate);
     }
--- a/browser/components/contextualidentity/test/browser/browser.ini
+++ b/browser/components/contextualidentity/test/browser/browser.ini
@@ -25,8 +25,12 @@ tags = openwindow
 tags = openwindow
 [browser_serviceworkers.js]
 [browser_broadcastchannel.js]
 [browser_blobUrl.js]
 [browser_middleClick.js]
 [browser_imageCache.js]
 [browser_count_and_remove.js]
 [browser_relatedTab.js]
+[browser_saveLink.js]
+support-files =
+  saveLink.sjs
+  !/toolkit/content/tests/browser/common/mockTransfer.js
new file mode 100644
--- /dev/null
+++ b/browser/components/contextualidentity/test/browser/browser_saveLink.js
@@ -0,0 +1,111 @@
+"use strict";
+
+const BASE_ORIGIN = "https://example.com";
+const URI = BASE_ORIGIN +
+  "/browser/browser/components/contextualidentity/test/browser/saveLink.sjs";
+
+let MockFilePicker = SpecialPowers.MockFilePicker;
+MockFilePicker.init(window);
+
+add_task(async function setup() {
+  info("Setting the prefs.");
+
+  // make sure userContext is enabled.
+  await SpecialPowers.pushPrefEnv({"set": [
+    ["privacy.userContext.enabled", true]
+  ]});
+});
+
+add_task(async function test() {
+  info("Let's open a new window");
+  let win = await BrowserTestUtils.openNewBrowserWindow();
+
+  info("Opening tab with UCI: 1");
+  let tab = BrowserTestUtils.addTab(win.gBrowser, URI + "?UCI=1", {userContextId: 1});
+
+  // select tab and make sure its browser is focused
+  win.gBrowser.selectedTab = tab;
+  tab.ownerGlobal.focus();
+
+  info("Waiting to load content");
+  let browser = gBrowser.getBrowserForTab(tab);
+  await BrowserTestUtils.browserLoaded(browser);
+
+  let popupShownPromise = BrowserTestUtils.waitForEvent(win.document, "popupshown");
+
+  await BrowserTestUtils.synthesizeMouseAtCenter("#fff", {type: "contextmenu", button: 2},
+                                                 win.gBrowser.selectedBrowser);
+  info("Right clicked!");
+
+  await popupShownPromise;
+  info("Context menu opened");
+
+  info("Let's create a temporary dir");
+  let tempDir = createTemporarySaveDirectory();
+  let destFile;
+
+  MockFilePicker.displayDirectory = tempDir;
+  MockFilePicker.showCallback = fp => {
+    info("MockFilePicker showCallback");
+
+    let fileName = fp.defaultString;
+    destFile = tempDir.clone();
+    destFile.append(fileName);
+
+    MockFilePicker.setFiles([destFile]);
+    MockFilePicker.filterIndex = 1; // kSaveAsType_URL
+
+    info("MockFilePicker showCallback done");
+  };
+
+  let transferCompletePromise = new Promise((resolve) => {
+    function onTransferComplete(downloadSuccess) {
+      ok(downloadSuccess, "File should have been downloaded successfully");
+      resolve();
+    }
+
+    mockTransferCallback = onTransferComplete;
+    mockTransferRegisterer.register();
+  });
+
+  registerCleanupFunction(function() {
+    mockTransferRegisterer.unregister();
+    MockFilePicker.cleanup();
+    tempDir.remove(true);
+  });
+
+  // Select "Save Link As" option from context menu
+  let saveLinkCommand = win.document.getElementById("context-savelink");
+  info("saveLinkCommand: " + saveLinkCommand);
+  saveLinkCommand.doCommand();
+
+  let contextMenu = win.document.getElementById("contentAreaContextMenu");
+  let popupHiddenPromise = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden");
+  contextMenu.hidePopup();
+  await popupHiddenPromise;
+  info("popup hidden");
+
+  await transferCompletePromise;
+
+  // Let's query the SJS to know if the download happened with the correct cookie.
+  let response = await fetch(URI + "?result=1");
+  let text = await response.text();
+  is(text, "Result:UCI=1", "Correct cookie used: -" + text + "-");
+
+  info("Closing the window");
+  await BrowserTestUtils.closeWindow(win);
+});
+
+/* import-globals-from ../../../../../toolkit/content/tests/browser/common/mockTransfer.js */
+Services.scriptloader.loadSubScript("chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockTransfer.js", this);
+
+function createTemporarySaveDirectory() {
+  let saveDir = Services.dirsvc.get("TmpD", Ci.nsIFile);
+  saveDir.append("testsavedir");
+  if (!saveDir.exists()) {
+    info("create testsavedir!");
+    saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
+  }
+  info("return from createTempSaveDir: " + saveDir.path);
+  return saveDir;
+}
new file mode 100644
--- /dev/null
+++ b/browser/components/contextualidentity/test/browser/saveLink.sjs
@@ -0,0 +1,45 @@
+const HTTP_ORIGIN = "http://example.com";
+const HTTPS_ORIGIN = "https://example.com";
+const URI_PATH = "/browser/browser/components/contextualidentity/test/browser/saveLink.sjs";
+
+Components.utils.importGlobalProperties(["URLSearchParams"]);
+
+function handleRequest(aRequest, aResponse) {
+  var params = new URLSearchParams(aRequest.queryString);
+
+  // This is the first request, where we set the cookie.
+  if (params.has("UCI")) {
+    aResponse.setStatusLine(aRequest.httpVersion, 200);
+    aResponse.setHeader("Set-Cookie", "UCI=" + params.get("UCI"));
+    aResponse.write("<html><body><a href='" + HTTPS_ORIGIN + URI_PATH + "?redirect=1' id='fff'>this is a link</a></body></html>");
+    return;
+  }
+
+  // Second request. This is the save-as content, but we make a redirect to see
+  // if we are able to follow it.
+  if (params.has("redirect")) {
+    aResponse.setStatusLine(aRequest.httpVersion, 302, "Found");
+    aResponse.setHeader("Location", HTTP_ORIGIN + URI_PATH + "?download=1", false);
+    aResponse.write("Redirect!");
+    return;
+  }
+
+  // This is the 3rd request where we offer the content to be saved.
+  if (params.has("download")) {
+    setState("downloadUCI", aRequest.getHeader("Cookie"));
+    aResponse.setStatusLine(aRequest.httpVersion, 200);
+    aResponse.write("All Good!");
+    return;
+  }
+
+  // This is the last request to check that the download happened with the correct cookie
+  if (params.has("result")) {
+    aResponse.setStatusLine(aRequest.httpVersion, 200);
+    aResponse.write("Result:" + getState("downloadUCI"));
+    return;
+  }
+
+  // We should not be here!
+  aResponse.setStatusLine(aRequest.httpVersion, 500);
+  aResponse.write("ERROR!!!");
+}
--- a/browser/components/translation/Translation.jsm
+++ b/browser/components/translation/Translation.jsm
@@ -343,31 +343,29 @@ this.TranslationTelemetry = {
    * has previously clicked "Never translate this language" or "Never
    * translate this site", which results in the infobar not being shown for
    * the translation opportunity.
    *
    * These translation opportunities should still be recorded in addition to
    * recording the automatic rejection of the offer.
    */
   recordAutoRejectedTranslationOffer() {
-    if (!this._canRecord) return;
     this.HISTOGRAMS.AUTO_REJECTED().add();
   },
 
    /**
    * Record a translation in the health report.
    * @param langFrom
    *        The language of the page.
    * @param langTo
    *        The language translated to
    * @param numCharacters
    *        The number of characters that were translated
    */
   recordTranslation(langFrom, langTo, numCharacters) {
-    if (!this._canRecord) return;
     this.HISTOGRAMS.PAGES().add();
     this.HISTOGRAMS.PAGES_BY_LANG().add(langFrom + " -> " + langTo);
     this.HISTOGRAMS.CHARACTERS().add(numCharacters);
   },
 
   /**
    * Record a change of the detected language in the health report. This should
    * only be called when actually executing a translation, not every time the
@@ -376,67 +374,53 @@ this.TranslationTelemetry = {
    * @param beforeFirstTranslation
    *        A boolean indicating if we are recording a change of detected
    *        language before translating the page for the first time. If we
    *        have already translated the page from the detected language and
    *        the user has manually adjusted the detected language false should
    *        be passed.
    */
   recordDetectedLanguageChange(beforeFirstTranslation) {
-    if (!this._canRecord) return;
     this.HISTOGRAMS.DETECTION_CHANGES().add(beforeFirstTranslation);
   },
 
   /**
    * Record a change of the target language in the health report. This should
    * only be called when actually executing a translation, not every time the
    * user changes in the language in the UI.
    */
   recordTargetLanguageChange() {
-    if (!this._canRecord) return;
     this.HISTOGRAMS.TARGET_CHANGES().add();
   },
 
   /**
    * Record a denied translation offer.
    */
   recordDeniedTranslationOffer() {
-    if (!this._canRecord) return;
     this.HISTOGRAMS.DENIED().add();
   },
 
   /**
    * Record a "Show Original" command use.
    */
   recordShowOriginalContent() {
-    if (!this._canRecord) return;
     this.HISTOGRAMS.SHOW_ORIGINAL().add();
   },
 
   /**
    * Record the state of translation preferences.
    */
   recordPreferences() {
-    if (!this._canRecord) return;
     if (Services.prefs.getBoolPref(TRANSLATION_PREF_SHOWUI)) {
       this.HISTOGRAMS.SHOW_UI().add(1);
     }
     if (Services.prefs.getBoolPref(TRANSLATION_PREF_DETECT_LANG)) {
       this.HISTOGRAMS.DETECT_LANG().add(1);
     }
   },
 
   _recordOpportunity(language, success) {
-    if (!this._canRecord) return;
     this.HISTOGRAMS.OPPORTUNITIES().add(success);
     this.HISTOGRAMS.OPPORTUNITIES_BY_LANG().add(language, success);
   },
-
-  /**
-   * A shortcut for reading the telemetry preference.
-   *
-   */
-  _canRecord() {
-    return Services.prefs.getBoolPref("toolkit.telemetry.enabled");
-  }
 };
 
 this.TranslationTelemetry.init();
new file mode 100644
--- /dev/null
+++ b/browser/config/tooltool-manifests/linux64/jsshell.manifest
@@ -0,0 +1,16 @@
+[
+  {
+    "size": 479280,
+    "digest": "dd7e9d67fc858f670502a16266963b15d8fb9a2fa4fc638ba1a27e17318b84ade5a9c1284783905dfbe113ce59690c9232c182e0466d53a37182e8aedea5530f",
+    "algorithm": "sha512",
+    "filename": "breakpad-tools.tar.xz",
+    "unpack": true
+  },
+  {
+    "size": 1737944,
+    "visibility": "public",
+    "digest": "76d704f0bfa110f5ea298b87200e34ec09d039b9d1a59ec819fc8e02b2cf073af32a4536dca33a3813f037a557fd0669b48a063c7a920f6308b307148029d41f",
+    "algorithm": "sha512",
+    "filename": "linux64-minidump_stackwalk"
+  }
+]
--- 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.106
+Current extension version is: 2.0.120
 
-Taken from upstream commit: 0052dc2b
+Taken from upstream commit: e162df59
--- a/browser/extensions/pdfjs/content/build/pdf.js
+++ b/browser/extensions/pdfjs/content/build/pdf.js
@@ -1956,17 +1956,17 @@ function getDocument(src) {
     });
   }).catch(task._capability.reject);
   return task;
 }
 function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
   if (worker.destroyed) {
     return Promise.reject(new Error('Worker was destroyed'));
   }
-  let apiVersion = '2.0.106';
+  let apiVersion = '2.0.120';
   source.disableAutoFetch = (0, _dom_utils.getDefaultSetting)('disableAutoFetch');
   source.disableStream = (0, _dom_utils.getDefaultSetting)('disableStream');
   source.chunkedViewerLoading = !!pdfDataRangeTransport;
   if (pdfDataRangeTransport) {
     source.length = pdfDataRangeTransport.length;
     source.initialData = pdfDataRangeTransport.initialData;
   }
   return worker.messageHandler.sendWithPromise('GetDocRequest', {
@@ -3253,18 +3253,18 @@ var InternalRenderTask = function Intern
         }
       }
     }
   };
   return InternalRenderTask;
 }();
 var version, build;
 {
-  exports.version = version = '2.0.106';
-  exports.build = build = '0052dc2b';
+  exports.version = version = '2.0.120';
+  exports.build = build = 'e162df59';
 }
 exports.getDocument = getDocument;
 exports.LoopbackPort = LoopbackPort;
 exports.PDFDataRangeTransport = PDFDataRangeTransport;
 exports.PDFWorker = PDFWorker;
 exports.PDFDocumentProxy = PDFDocumentProxy;
 exports.PDFPageProxy = PDFPageProxy;
 exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
@@ -4988,18 +4988,18 @@ exports.SVGGraphics = SVGGraphics;
 
 /***/ }),
 /* 9 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-var pdfjsVersion = '2.0.106';
-var pdfjsBuild = '0052dc2b';
+var pdfjsVersion = '2.0.120';
+var pdfjsBuild = 'e162df59';
 var pdfjsSharedUtil = __w_pdfjs_require__(0);
 var pdfjsDisplayGlobal = __w_pdfjs_require__(13);
 var pdfjsDisplayAPI = __w_pdfjs_require__(3);
 var pdfjsDisplayTextLayer = __w_pdfjs_require__(7);
 var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(6);
 var pdfjsDisplayDOMUtils = __w_pdfjs_require__(1);
 var pdfjsDisplaySVG = __w_pdfjs_require__(8);
 ;
@@ -8113,18 +8113,18 @@ var _svg = __w_pdfjs_require__(8);
 
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
 if (!_global_scope2.default.PDFJS) {
   _global_scope2.default.PDFJS = {};
 }
 var PDFJS = _global_scope2.default.PDFJS;
 {
-  PDFJS.version = '2.0.106';
-  PDFJS.build = '0052dc2b';
+  PDFJS.version = '2.0.120';
+  PDFJS.build = 'e162df59';
 }
 PDFJS.pdfBug = false;
 if (PDFJS.verbosity !== undefined) {
   (0, _util.setVerbosityLevel)(PDFJS.verbosity);
 }
 delete PDFJS.verbosity;
 Object.defineProperty(PDFJS, 'verbosity', {
   get() {
--- a/browser/extensions/pdfjs/content/build/pdf.worker.js
+++ b/browser/extensions/pdfjs/content/build/pdf.worker.js
@@ -1694,17 +1694,17 @@ Object.defineProperty(exports, "__esModu
 exports.LZWStream = exports.StringStream = exports.StreamsSequenceStream = exports.Stream = exports.RunLengthStream = exports.PredictorStream = exports.NullStream = exports.JpxStream = exports.JpegStream = exports.FlateStream = exports.DecodeStream = exports.DecryptStream = exports.AsciiHexStream = exports.Ascii85Stream = undefined;
 
 var _util = __w_pdfjs_require__(0);
 
 var _primitives = __w_pdfjs_require__(1);
 
 var _jpg = __w_pdfjs_require__(24);
 
-var _jpx = __w_pdfjs_require__(9);
+var _jpx = __w_pdfjs_require__(10);
 
 var Stream = function StreamClosure() {
   function Stream(arrayBuffer, start, length, dict) {
     this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
     this.start = start || 0;
     this.pos = this.start;
     this.end = start + length || this.bytes.length;
     this.dict = dict;
@@ -4747,16 +4747,544 @@ var Linearization = {
 exports.Lexer = Lexer;
 exports.Linearization = Linearization;
 exports.Parser = Parser;
 
 /***/ }),
 /* 6 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.OperatorList = undefined;
+
+var _util = __w_pdfjs_require__(0);
+
+var QueueOptimizer = function QueueOptimizerClosure() {
+  function addState(parentState, pattern, checkFn, iterateFn, processFn) {
+    var state = parentState;
+    for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
+      var item = pattern[i];
+      state = state[item] || (state[item] = []);
+    }
+    state[pattern[pattern.length - 1]] = {
+      checkFn,
+      iterateFn,
+      processFn
+    };
+  }
+  function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
+    var iFirstPIMXO = iFirstSave + 2;
+    for (var i = 0; i < count; i++) {
+      var arg = argsArray[iFirstPIMXO + 4 * i];
+      var imageMask = arg.length === 1 && arg[0];
+      if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
+        fnArray[iFirstPIMXO + 4 * i] = _util.OPS.paintSolidColorImageMask;
+        continue;
+      }
+      break;
+    }
+    return count - i;
+  }
+  var InitialState = [];
+  addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintInlineImageXObject, _util.OPS.restore], null, function iterateInlineImageGroup(context, i) {
+    var fnArray = context.fnArray;
+    var iFirstSave = context.iCurr - 3;
+    var pos = (i - iFirstSave) % 4;
+    switch (pos) {
+      case 0:
+        return fnArray[i] === _util.OPS.save;
+      case 1:
+        return fnArray[i] === _util.OPS.transform;
+      case 2:
+        return fnArray[i] === _util.OPS.paintInlineImageXObject;
+      case 3:
+        return fnArray[i] === _util.OPS.restore;
+    }
+  }, function foundInlineImageGroup(context, i) {
+    var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
+    var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
+    var MAX_WIDTH = 1000;
+    var IMAGE_PADDING = 1;
+    var fnArray = context.fnArray,
+        argsArray = context.argsArray;
+    var curr = context.iCurr;
+    var iFirstSave = curr - 3;
+    var iFirstTransform = curr - 2;
+    var iFirstPIIXO = curr - 1;
+    var count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
+    if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
+      return i - (i - iFirstSave) % 4;
+    }
+    var maxX = 0;
+    var map = [],
+        maxLineHeight = 0;
+    var currentX = IMAGE_PADDING,
+        currentY = IMAGE_PADDING;
+    var q;
+    for (q = 0; q < count; q++) {
+      var transform = argsArray[iFirstTransform + (q << 2)];
+      var img = argsArray[iFirstPIIXO + (q << 2)][0];
+      if (currentX + img.width > MAX_WIDTH) {
+        maxX = Math.max(maxX, currentX);
+        currentY += maxLineHeight + 2 * IMAGE_PADDING;
+        currentX = 0;
+        maxLineHeight = 0;
+      }
+      map.push({
+        transform,
+        x: currentX,
+        y: currentY,
+        w: img.width,
+        h: img.height
+      });
+      currentX += img.width + 2 * IMAGE_PADDING;
+      maxLineHeight = Math.max(maxLineHeight, img.height);
+    }
+    var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
+    var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
+    var imgData = new Uint8Array(imgWidth * imgHeight * 4);
+    var imgRowSize = imgWidth << 2;
+    for (q = 0; q < count; q++) {
+      var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
+      var rowSize = map[q].w << 2;
+      var dataOffset = 0;
+      var offset = map[q].x + map[q].y * imgWidth << 2;
+      imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
+      for (var k = 0, kk = map[q].h; k < kk; k++) {
+        imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
+        dataOffset += rowSize;
+        offset += imgRowSize;
+      }
+      imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
+      while (offset >= 0) {
+        data[offset - 4] = data[offset];
+        data[offset - 3] = data[offset + 1];
+        data[offset - 2] = data[offset + 2];
+        data[offset - 1] = data[offset + 3];
+        data[offset + rowSize] = data[offset + rowSize - 4];
+        data[offset + rowSize + 1] = data[offset + rowSize - 3];
+        data[offset + rowSize + 2] = data[offset + rowSize - 2];
+        data[offset + rowSize + 3] = data[offset + rowSize - 1];
+        offset -= imgRowSize;
+      }
+    }
+    fnArray.splice(iFirstSave, count * 4, _util.OPS.paintInlineImageXObjectGroup);
+    argsArray.splice(iFirstSave, count * 4, [{
+      width: imgWidth,
+      height: imgHeight,
+      kind: _util.ImageKind.RGBA_32BPP,
+      data: imgData
+    }, map]);
+    return iFirstSave + 1;
+  });
+  addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintImageMaskXObject, _util.OPS.restore], null, function iterateImageMaskGroup(context, i) {
+    var fnArray = context.fnArray;
+    var iFirstSave = context.iCurr - 3;
+    var pos = (i - iFirstSave) % 4;
+    switch (pos) {
+      case 0:
+        return fnArray[i] === _util.OPS.save;
+      case 1:
+        return fnArray[i] === _util.OPS.transform;
+      case 2:
+        return fnArray[i] === _util.OPS.paintImageMaskXObject;
+      case 3:
+        return fnArray[i] === _util.OPS.restore;
+    }
+  }, function foundImageMaskGroup(context, i) {
+    var MIN_IMAGES_IN_MASKS_BLOCK = 10;
+    var MAX_IMAGES_IN_MASKS_BLOCK = 100;
+    var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
+    var fnArray = context.fnArray,
+        argsArray = context.argsArray;
+    var curr = context.iCurr;
+    var iFirstSave = curr - 3;
+    var iFirstTransform = curr - 2;
+    var iFirstPIMXO = curr - 1;
+    var count = Math.floor((i - iFirstSave) / 4);
+    count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
+    if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
+      return i - (i - iFirstSave) % 4;
+    }
+    var q;
+    var isSameImage = false;
+    var iTransform, transformArgs;
+    var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
+    if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
+      isSameImage = true;
+      var firstTransformArg0 = argsArray[iFirstTransform][0];
+      var firstTransformArg3 = argsArray[iFirstTransform][3];
+      iTransform = iFirstTransform + 4;
+      var iPIMXO = iFirstPIMXO + 4;
+      for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
+        transformArgs = argsArray[iTransform];
+        if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
+          if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
+            isSameImage = false;
+          } else {
+            count = q;
+          }
+          break;
+        }
+      }
+    }
+    if (isSameImage) {
+      count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
+      var positions = new Float32Array(count * 2);
+      iTransform = iFirstTransform;
+      for (q = 0; q < count; q++, iTransform += 4) {
+        transformArgs = argsArray[iTransform];
+        positions[q << 1] = transformArgs[4];
+        positions[(q << 1) + 1] = transformArgs[5];
+      }
+      fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageMaskXObjectRepeat);
+      argsArray.splice(iFirstSave, count * 4, [firstPIMXOArg0, firstTransformArg0, firstTransformArg3, positions]);
+    } else {
+      count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
+      var images = [];
+      for (q = 0; q < count; q++) {
+        transformArgs = argsArray[iFirstTransform + (q << 2)];
+        var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
+        images.push({
+          data: maskParams.data,
+          width: maskParams.width,
+          height: maskParams.height,
+          transform: transformArgs
+        });
+      }
+      fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageMaskXObjectGroup);
+      argsArray.splice(iFirstSave, count * 4, [images]);
+    }
+    return iFirstSave + 1;
+  });
+  addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintImageXObject, _util.OPS.restore], function (context) {
+    var argsArray = context.argsArray;
+    var iFirstTransform = context.iCurr - 2;
+    return argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0;
+  }, function (context, i) {
+    var fnArray = context.fnArray,
+        argsArray = context.argsArray;
+    var iFirstSave = context.iCurr - 3;
+    var pos = (i - iFirstSave) % 4;
+    switch (pos) {
+      case 0:
+        return fnArray[i] === _util.OPS.save;
+      case 1:
+        if (fnArray[i] !== _util.OPS.transform) {
+          return false;
+        }
+        var iFirstTransform = context.iCurr - 2;
+        var firstTransformArg0 = argsArray[iFirstTransform][0];
+        var firstTransformArg3 = argsArray[iFirstTransform][3];
+        if (argsArray[i][0] !== firstTransformArg0 || argsArray[i][1] !== 0 || argsArray[i][2] !== 0 || argsArray[i][3] !== firstTransformArg3) {
+          return false;
+        }
+        return true;
+      case 2:
+        if (fnArray[i] !== _util.OPS.paintImageXObject) {
+          return false;
+        }
+        var iFirstPIXO = context.iCurr - 1;
+        var firstPIXOArg0 = argsArray[iFirstPIXO][0];
+        if (argsArray[i][0] !== firstPIXOArg0) {
+          return false;
+        }
+        return true;
+      case 3:
+        return fnArray[i] === _util.OPS.restore;
+    }
+  }, function (context, i) {
+    var MIN_IMAGES_IN_BLOCK = 3;
+    var MAX_IMAGES_IN_BLOCK = 1000;
+    var fnArray = context.fnArray,
+        argsArray = context.argsArray;
+    var curr = context.iCurr;
+    var iFirstSave = curr - 3;
+    var iFirstTransform = curr - 2;
+    var iFirstPIXO = curr - 1;
+    var firstPIXOArg0 = argsArray[iFirstPIXO][0];
+    var firstTransformArg0 = argsArray[iFirstTransform][0];
+    var firstTransformArg3 = argsArray[iFirstTransform][3];
+    var count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_BLOCK);
+    if (count < MIN_IMAGES_IN_BLOCK) {
+      return i - (i - iFirstSave) % 4;
+    }
+    var positions = new Float32Array(count * 2);
+    var iTransform = iFirstTransform;
+    for (var q = 0; q < count; q++, iTransform += 4) {
+      var transformArgs = argsArray[iTransform];
+      positions[q << 1] = transformArgs[4];
+      positions[(q << 1) + 1] = transformArgs[5];
+    }
+    var args = [firstPIXOArg0, firstTransformArg0, firstTransformArg3, positions];
+    fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageXObjectRepeat);
+    argsArray.splice(iFirstSave, count * 4, args);
+    return iFirstSave + 1;
+  });
+  addState(InitialState, [_util.OPS.beginText, _util.OPS.setFont, _util.OPS.setTextMatrix, _util.OPS.showText, _util.OPS.endText], null, function (context, i) {
+    var fnArray = context.fnArray,
+        argsArray = context.argsArray;
+    var iFirstSave = context.iCurr - 4;
+    var pos = (i - iFirstSave) % 5;
+    switch (pos) {
+      case 0:
+        return fnArray[i] === _util.OPS.beginText;
+      case 1:
+        return fnArray[i] === _util.OPS.setFont;
+      case 2:
+        return fnArray[i] === _util.OPS.setTextMatrix;
+      case 3:
+        if (fnArray[i] !== _util.OPS.showText) {
+          return false;
+        }
+        var iFirstSetFont = context.iCurr - 3;
+        var firstSetFontArg0 = argsArray[iFirstSetFont][0];
+        var firstSetFontArg1 = argsArray[iFirstSetFont][1];
+        if (argsArray[i][0] !== firstSetFontArg0 || argsArray[i][1] !== firstSetFontArg1) {
+          return false;
+        }
+        return true;
+      case 4:
+        return fnArray[i] === _util.OPS.endText;
+    }
+  }, function (context, i) {
+    var MIN_CHARS_IN_BLOCK = 3;
+    var MAX_CHARS_IN_BLOCK = 1000;
+    var fnArray = context.fnArray,
+        argsArray = context.argsArray;
+    var curr = context.iCurr;
+    var iFirstBeginText = curr - 4;
+    var iFirstSetFont = curr - 3;
+    var iFirstSetTextMatrix = curr - 2;
+    var iFirstShowText = curr - 1;
+    var iFirstEndText = curr;
+    var firstSetFontArg0 = argsArray[iFirstSetFont][0];
+    var firstSetFontArg1 = argsArray[iFirstSetFont][1];
+    var count = Math.min(Math.floor((i - iFirstBeginText) / 5), MAX_CHARS_IN_BLOCK);
+    if (count < MIN_CHARS_IN_BLOCK) {
+      return i - (i - iFirstBeginText) % 5;
+    }
+    var iFirst = iFirstBeginText;
+    if (iFirstBeginText >= 4 && fnArray[iFirstBeginText - 4] === fnArray[iFirstSetFont] && fnArray[iFirstBeginText - 3] === fnArray[iFirstSetTextMatrix] && fnArray[iFirstBeginText - 2] === fnArray[iFirstShowText] && fnArray[iFirstBeginText - 1] === fnArray[iFirstEndText] && argsArray[iFirstBeginText - 4][0] === firstSetFontArg0 && argsArray[iFirstBeginText - 4][1] === firstSetFontArg1) {
+      count++;
+      iFirst -= 5;
+    }
+    var iEndText = iFirst + 4;
+    for (var q = 1; q < count; q++) {
+      fnArray.splice(iEndText, 3);
+      argsArray.splice(iEndText, 3);
+      iEndText += 2;
+    }
+    return iEndText + 1;
+  });
+  function QueueOptimizer(queue) {
+    this.queue = queue;
+    this.state = null;
+    this.context = {
+      iCurr: 0,
+      fnArray: queue.fnArray,
+      argsArray: queue.argsArray
+    };
+    this.match = null;
+    this.lastProcessed = 0;
+  }
+  QueueOptimizer.prototype = {
+    _optimize() {
+      const fnArray = this.queue.fnArray;
+      let i = this.lastProcessed,
+          ii = fnArray.length;
+      let state = this.state;
+      let match = this.match;
+      if (!state && !match && i + 1 === ii && !InitialState[fnArray[i]]) {
+        this.lastProcessed = ii;
+        return;
+      }
+      const context = this.context;
+      while (i < ii) {
+        if (match) {
+          const iterate = (0, match.iterateFn)(context, i);
+          if (iterate) {
+            i++;
+            continue;
+          }
+          i = (0, match.processFn)(context, i + 1);
+          ii = fnArray.length;
+          match = null;
+          state = null;
+          if (i >= ii) {
+            break;
+          }
+        }
+        state = (state || InitialState)[fnArray[i]];
+        if (!state || Array.isArray(state)) {
+          i++;
+          continue;
+        }
+        context.iCurr = i;
+        i++;
+        if (state.checkFn && !(0, state.checkFn)(context)) {
+          state = null;
+          continue;
+        }
+        match = state;
+        state = null;
+      }
+      this.state = state;
+      this.match = match;
+      this.lastProcessed = i;
+    },
+    push(fn, args) {
+      this.queue.fnArray.push(fn);
+      this.queue.argsArray.push(args);
+      this._optimize();
+    },
+    flush() {
+      while (this.match) {
+        const length = this.queue.fnArray.length;
+        this.lastProcessed = (0, this.match.processFn)(this.context, length);
+        this.match = null;
+        this.state = null;
+        this._optimize();
+      }
+    },
+    reset() {
+      this.state = null;
+      this.match = null;
+      this.lastProcessed = 0;
+    }
+  };
+  return QueueOptimizer;
+}();
+var NullOptimizer = function NullOptimizerClosure() {
+  function NullOptimizer(queue) {
+    this.queue = queue;
+  }
+  NullOptimizer.prototype = {
+    push(fn, args) {
+      this.queue.fnArray.push(fn);
+      this.queue.argsArray.push(args);
+    },
+    flush() {}
+  };
+  return NullOptimizer;
+}();
+var OperatorList = function OperatorListClosure() {
+  var CHUNK_SIZE = 1000;
+  var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
+  function getTransfers(queue) {
+    var transfers = [];
+    var fnArray = queue.fnArray,
+        argsArray = queue.argsArray;
+    for (var i = 0, ii = queue.length; i < ii; i++) {
+      switch (fnArray[i]) {
+        case _util.OPS.paintInlineImageXObject:
+        case _util.OPS.paintInlineImageXObjectGroup:
+        case _util.OPS.paintImageMaskXObject:
+          var arg = argsArray[i][0];
+          if (!arg.cached) {
+            transfers.push(arg.data.buffer);
+          }
+          break;
+      }
+    }
+    return transfers;
+  }
+  function OperatorList(intent, messageHandler, pageIndex) {
+    this.messageHandler = messageHandler;
+    this.fnArray = [];
+    this.argsArray = [];
+    if (messageHandler && this.intent !== 'oplist') {
+      this.optimizer = new QueueOptimizer(this);
+    } else {
+      this.optimizer = new NullOptimizer(this);
+    }
+    this.dependencies = Object.create(null);
+    this._totalLength = 0;
+    this.pageIndex = pageIndex;
+    this.intent = intent;
+    this.weight = 0;
+  }
+  OperatorList.prototype = {
+    get length() {
+      return this.argsArray.length;
+    },
+    get totalLength() {
+      return this._totalLength + this.length;
+    },
+    addOp(fn, args) {
+      this.optimizer.push(fn, args);
+      this.weight++;
+      if (this.messageHandler) {
+        if (this.weight >= CHUNK_SIZE) {
+          this.flush();
+        } else if (this.weight >= CHUNK_SIZE_ABOUT && (fn === _util.OPS.restore || fn === _util.OPS.endText)) {
+          this.flush();
+        }
+      }
+    },
+    addDependency(dependency) {
+      if (dependency in this.dependencies) {
+        return;
+      }
+      this.dependencies[dependency] = true;
+      this.addOp(_util.OPS.dependency, [dependency]);
+    },
+    addDependencies(dependencies) {
+      for (var key in dependencies) {
+        this.addDependency(key);
+      }
+    },
+    addOpList(opList) {
+      _util.Util.extendObj(this.dependencies, opList.dependencies);
+      for (var i = 0, ii = opList.length; i < ii; i++) {
+        this.addOp(opList.fnArray[i], opList.argsArray[i]);
+      }
+    },
+    getIR() {
+      return {
+        fnArray: this.fnArray,
+        argsArray: this.argsArray,
+        length: this.length
+      };
+    },
+    flush(lastChunk) {
+      this.optimizer.flush();
+      var transfers = getTransfers(this);
+      var length = this.length;
+      this._totalLength += length;
+      this.messageHandler.send('RenderPageChunk', {
+        operatorList: {
+          fnArray: this.fnArray,
+          argsArray: this.argsArray,
+          lastChunk,
+          length
+        },
+        pageIndex: this.pageIndex,
+        intent: this.intent
+      }, transfers);
+      this.dependencies = Object.create(null);
+      this.fnArray.length = 0;
+      this.argsArray.length = 0;
+      this.weight = 0;
+      this.optimizer.reset();
+    }
+  };
+  return OperatorList;
+}();
+exports.OperatorList = OperatorList;
+
+/***/ }),
+/* 7 */
+/***/ (function(module, exports, __w_pdfjs_require__) {
+
 var getLookupTableFactory = __w_pdfjs_require__(0).getLookupTableFactory;
 var getGlyphsUnicode = getLookupTableFactory(function (t) {
  t['A'] = 0x0041;
  t['AE'] = 0x00C6;
  t['AEacute'] = 0x01FC;
  t['AEmacron'] = 0x01E2;
  t['AEsmall'] = 0xF7E6;
  t['Aacute'] = 0x00C1;
@@ -9280,17 +9808,17 @@ var getDingbatsGlyphsUnicode = getLookup
  t['a95'] = 0x2774;
  t['a96'] = 0x2775;
  t['.notdef'] = 0x0000;
 });
 exports.getGlyphsUnicode = getGlyphsUnicode;
 exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
 
 /***/ }),
-/* 7 */
+/* 8 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -9748,36 +10276,36 @@ var ChunkedStreamManager = function Chun
     }
   };
   return ChunkedStreamManager;
 }();
 exports.ChunkedStream = ChunkedStream;
 exports.ChunkedStreamManager = ChunkedStreamManager;
 
 /***/ }),
-/* 8 */
+/* 9 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.FileSpec = exports.XRef = exports.ObjectLoader = exports.Catalog = undefined;
 
 var _util = __w_pdfjs_require__(0);
 
 var _primitives = __w_pdfjs_require__(1);
 
 var _parser = __w_pdfjs_require__(5);
 
-var _chunked_stream = __w_pdfjs_require__(7);
-
-var _crypto = __w_pdfjs_require__(11);
+var _chunked_stream = __w_pdfjs_require__(8);
+
+var _crypto = __w_pdfjs_require__(12);
 
 var _colorspace = __w_pdfjs_require__(3);
 
 var Catalog = function CatalogClosure() {
   function Catalog(pdfManager, xref, pageFactory) {
     this.pdfManager = pdfManager;
     this.xref = xref;
     this.catDict = xref.getCatalogObj();
@@ -11257,30 +11785,30 @@ let ObjectLoader = function () {
   return ObjectLoader;
 }();
 exports.Catalog = Catalog;
 exports.ObjectLoader = ObjectLoader;
 exports.XRef = XRef;
 exports.FileSpec = FileSpec;
 
 /***/ }),
-/* 9 */
+/* 10 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.JpxImage = undefined;
 
 var _util = __w_pdfjs_require__(0);
 
-var _arithmetic_decoder = __w_pdfjs_require__(10);
+var _arithmetic_decoder = __w_pdfjs_require__(11);
 
 let JpxError = function JpxErrorClosure() {
   function JpxError(msg) {
     this.message = 'JPX error: ' + msg;
   }
   JpxError.prototype = new Error();
   JpxError.prototype.name = 'JpxError';
   JpxError.constructor = JpxError;
@@ -13184,17 +13712,17 @@ var JpxImage = function JpxImageClosure(
     };
     return ReversibleTransform;
   }();
   return JpxImage;
 }();
 exports.JpxImage = JpxImage;
 
 /***/ }),
-/* 10 */
+/* 11 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -13524,17 +14052,17 @@ var ArithmeticDecoder = function Arithme
       return d;
     }
   };
   return ArithmeticDecoder;
 }();
 exports.ArithmeticDecoder = ArithmeticDecoder;
 
 /***/ }),
-/* 11 */
+/* 12 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -15118,3081 +15646,30 @@ exports.CipherTransformFactory = CipherT
 exports.PDF17 = PDF17;
 exports.PDF20 = PDF20;
 exports.calculateMD5 = calculateMD5;
 exports.calculateSHA256 = calculateSHA256;
 exports.calculateSHA384 = calculateSHA384;
 exports.calculateSHA512 = calculateSHA512;
 
 /***/ }),
-/* 12 */
-/***/ (function(module, exports, __w_pdfjs_require__) {
-
-"use strict";
-
-
-Object.defineProperty(exports, "__esModule", {
-  value: true
-});
-exports.PartialEvaluator = exports.OperatorList = undefined;
-
-var _util = __w_pdfjs_require__(0);
-
-var _cmap = __w_pdfjs_require__(29);
-
-var _stream = __w_pdfjs_require__(2);
-
-var _primitives = __w_pdfjs_require__(1);
-
-var _fonts = __w_pdfjs_require__(30);
-
-var _encodings = __w_pdfjs_require__(4);
-
-var _unicode = __w_pdfjs_require__(15);
-
-var _standard_fonts = __w_pdfjs_require__(14);
-
-var _pattern = __w_pdfjs_require__(34);
-
-var _parser = __w_pdfjs_require__(5);
-
-var _bidi = __w_pdfjs_require__(35);
-
-var _colorspace = __w_pdfjs_require__(3);
-
-var _glyphlist = __w_pdfjs_require__(6);
-
-var _metrics = __w_pdfjs_require__(36);
-
-var _function = __w_pdfjs_require__(16);
-
-var _murmurhash = __w_pdfjs_require__(38);
-
-var _image = __w_pdfjs_require__(39);
-
-var PartialEvaluator = function PartialEvaluatorClosure() {
-  const DefaultPartialEvaluatorOptions = {
-    forceDataSchema: false,
-    maxImageSize: -1,
-    disableFontFace: false,
-    nativeImageDecoderSupport: _util.NativeImageDecoding.DECODE,
-    ignoreErrors: false,
-    isEvalSupported: true
-  };
-  function NativeImageDecoder({ xref, resources, handler, forceDataSchema = false, pdfFunctionFactory }) {
-    this.xref = xref;
-    this.resources = resources;
-    this.handler = handler;
-    this.forceDataSchema = forceDataSchema;
-    this.pdfFunctionFactory = pdfFunctionFactory;
-  }
-  NativeImageDecoder.prototype = {
-    canDecode(image) {
-      return image instanceof _stream.JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources, this.pdfFunctionFactory);
-    },
-    decode(image) {
-      var dict = image.dict;
-      var colorSpace = dict.get('ColorSpace', 'CS');
-      colorSpace = _colorspace.ColorSpace.parse(colorSpace, this.xref, this.resources, this.pdfFunctionFactory);
-      var numComps = colorSpace.numComps;
-      var decodePromise = this.handler.sendWithPromise('JpegDecode', [image.getIR(this.forceDataSchema), numComps]);
-      return decodePromise.then(function (message) {
-        var data = message.data;
-        return new _stream.Stream(data, 0, data.length, image.dict);
-      });
-    }
-  };
-  NativeImageDecoder.isSupported = function (image, xref, res, pdfFunctionFactory) {
-    var dict = image.dict;
-    if (dict.has('DecodeParms') || dict.has('DP')) {
-      return false;
-    }
-    var cs = _colorspace.ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res, pdfFunctionFactory);
-    return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
-  };
-  NativeImageDecoder.isDecodable = function (image, xref, res, pdfFunctionFactory) {
-    var dict = image.dict;
-    if (dict.has('DecodeParms') || dict.has('DP')) {
-      return false;
-    }
-    var cs = _colorspace.ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res, pdfFunctionFactory);
-    return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
-  };
-  function PartialEvaluator({ pdfManager, xref, handler, pageIndex, idFactory, fontCache, builtInCMapCache, options = null, pdfFunctionFactory }) {
-    this.pdfManager = pdfManager;
-    this.xref = xref;
-    this.handler = handler;
-    this.pageIndex = pageIndex;
-    this.idFactory = idFactory;
-    this.fontCache = fontCache;
-    this.builtInCMapCache = builtInCMapCache;
-    this.options = options || DefaultPartialEvaluatorOptions;
-    this.pdfFunctionFactory = pdfFunctionFactory;
-    this.fetchBuiltInCMap = name => {
-      var cachedCMap = this.builtInCMapCache[name];
-      if (cachedCMap) {
-        return Promise.resolve(cachedCMap);
-      }
-      return this.handler.sendWithPromise('FetchBuiltInCMap', { name }).then(data => {
-        if (data.compressionType !== _util.CMapCompressionType.NONE) {
-          this.builtInCMapCache[name] = data;
-        }
-        return data;
-      });
-    };
-  }
-  var TIME_SLOT_DURATION_MS = 20;
-  var CHECK_TIME_EVERY = 100;
-  function TimeSlotManager() {
-    this.reset();
-  }
-  TimeSlotManager.prototype = {
-    check: function TimeSlotManager_check() {
-      if (++this.checked < CHECK_TIME_EVERY) {
-        return false;
-      }
-      this.checked = 0;
-      return this.endTime <= Date.now();
-    },
-    reset: function TimeSlotManager_reset() {
-      this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
-      this.checked = 0;
-    }
-  };
-  function normalizeBlendMode(value) {
-    if (!(0, _primitives.isName)(value)) {
-      return 'source-over';
-    }
-    switch (value.name) {
-      case 'Normal':
-      case 'Compatible':
-        return 'source-over';
-      case 'Multiply':
-        return 'multiply';
-      case 'Screen':
-        return 'screen';
-      case 'Overlay':
-        return 'overlay';
-      case 'Darken':
-        return 'darken';
-      case 'Lighten':
-        return 'lighten';
-      case 'ColorDodge':
-        return 'color-dodge';
-      case 'ColorBurn':
-        return 'color-burn';
-      case 'HardLight':
-        return 'hard-light';
-      case 'SoftLight':
-        return 'soft-light';
-      case 'Difference':
-        return 'difference';
-      case 'Exclusion':
-        return 'exclusion';
-      case 'Hue':
-        return 'hue';
-      case 'Saturation':
-        return 'saturation';
-      case 'Color':
-        return 'color';
-      case 'Luminosity':
-        return 'luminosity';
-    }
-    (0, _util.warn)('Unsupported blend mode: ' + value.name);
-    return 'source-over';
-  }
-  var deferred = Promise.resolve();
-  var TILING_PATTERN = 1,
-      SHADING_PATTERN = 2;
-  PartialEvaluator.prototype = {
-    clone(newOptions = DefaultPartialEvaluatorOptions) {
-      var newEvaluator = Object.create(this);
-      newEvaluator.options = newOptions;
-      return newEvaluator;
-    },
-    hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
-      if (!(0, _primitives.isDict)(resources)) {
-        return false;
-      }
-      var processed = Object.create(null);
-      if (resources.objId) {
-        processed[resources.objId] = true;
-      }
-      var nodes = [resources],
-          xref = this.xref;
-      while (nodes.length) {
-        var key, i, ii;
-        var node = nodes.shift();
-        var graphicStates = node.get('ExtGState');
-        if ((0, _primitives.isDict)(graphicStates)) {
-          var graphicStatesKeys = graphicStates.getKeys();
-          for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
-            key = graphicStatesKeys[i];
-            var graphicState = graphicStates.get(key);
-            var bm = graphicState.get('BM');
-            if ((0, _primitives.isName)(bm) && bm.name !== 'Normal') {
-              return true;
-            }
-          }
-        }
-        var xObjects = node.get('XObject');
-        if (!(0, _primitives.isDict)(xObjects)) {
-          continue;
-        }
-        var xObjectsKeys = xObjects.getKeys();
-        for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
-          key = xObjectsKeys[i];
-          var xObject = xObjects.getRaw(key);
-          if ((0, _primitives.isRef)(xObject)) {
-            if (processed[xObject.toString()]) {
-              continue;
-            }
-            xObject = xref.fetch(xObject);
-          }
-          if (!(0, _primitives.isStream)(xObject)) {
-            continue;
-          }
-          if (xObject.dict.objId) {
-            if (processed[xObject.dict.objId]) {
-              continue;
-            }
-            processed[xObject.dict.objId] = true;
-          }
-          var xResources = xObject.dict.get('Resources');
-          if ((0, _primitives.isDict)(xResources) && (!xResources.objId || !processed[xResources.objId])) {
-            nodes.push(xResources);
-            if (xResources.objId) {
-              processed[xResources.objId] = true;
-            }
-          }
-        }
-      }
-      return false;
-    },
-    buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
-      var dict = xobj.dict;
-      var matrix = dict.getArray('Matrix');
-      var bbox = dict.getArray('BBox');
-      var group = dict.get('Group');
-      if (group) {
-        var groupOptions = {
-          matrix,
-          bbox,
-          smask,
-          isolated: false,
-          knockout: false
-        };
-        var groupSubtype = group.get('S');
-        var colorSpace = null;
-        if ((0, _primitives.isName)(groupSubtype, 'Transparency')) {
-          groupOptions.isolated = group.get('I') || false;
-          groupOptions.knockout = group.get('K') || false;
-          if (group.has('CS')) {
-            colorSpace = _colorspace.ColorSpace.parse(group.get('CS'), this.xref, resources, this.pdfFunctionFactory);
-          }
-        }
-        if (smask && smask.backdrop) {
-          colorSpace = colorSpace || _colorspace.ColorSpace.singletons.rgb;
-          smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
-        }
-        operatorList.addOp(_util.OPS.beginGroup, [groupOptions]);
-      }
-      operatorList.addOp(_util.OPS.paintFormXObjectBegin, [matrix, bbox]);
-      return this.getOperatorList({
-        stream: xobj,
-        task,
-        resources: dict.get('Resources') || resources,
-        operatorList,
-        initialState
-      }).then(function () {
-        operatorList.addOp(_util.OPS.paintFormXObjectEnd, []);
-        if (group) {
-          operatorList.addOp(_util.OPS.endGroup, [groupOptions]);
-        }
-      });
-    },
-    buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
-      var dict = image.dict;
-      var w = dict.get('Width', 'W');
-      var h = dict.get('Height', 'H');
-      if (!(w && (0, _util.isNum)(w)) || !(h && (0, _util.isNum)(h))) {
-        (0, _util.warn)('Image dimensions are missing, or not numbers.');
-        return;
-      }
-      var maxImageSize = this.options.maxImageSize;
-      if (maxImageSize !== -1 && w * h > maxImageSize) {
-        (0, _util.warn)('Image exceeded maximum allowed size and was removed.');
-        return;
-      }
-      var imageMask = dict.get('ImageMask', 'IM') || false;
-      var imgData, args;
-      if (imageMask) {
-        var width = dict.get('Width', 'W');
-        var height = dict.get('Height', 'H');
-        var bitStrideLength = width + 7 >> 3;
-        var imgArray = image.getBytes(bitStrideLength * height);
-        var decode = dict.getArray('Decode', 'D');
-        imgData = _image.PDFImage.createMask({
-          imgArray,
-          width,
-          height,
-          imageIsFromDecodeStream: image instanceof _stream.DecodeStream,
-          inverseDecode: !!decode && decode[0] > 0
-        });
-        imgData.cached = true;
-        args = [imgData];
-        operatorList.addOp(_util.OPS.paintImageMaskXObject, args);
-        if (cacheKey) {
-          imageCache[cacheKey] = {
-            fn: _util.OPS.paintImageMaskXObject,
-            args
-          };
-        }
-        return;
-      }
-      var softMask = dict.get('SMask', 'SM') || false;
-      var mask = dict.get('Mask') || false;
-      var SMALL_IMAGE_DIMENSIONS = 200;
-      if (inline && !softMask && !mask && !(image instanceof _stream.JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
-        let imageObj = new _image.PDFImage({
-          xref: this.xref,
-          res: resources,
-          image,
-          pdfFunctionFactory: this.pdfFunctionFactory
-        });
-        imgData = imageObj.createImageData(true);
-        operatorList.addOp(_util.OPS.paintInlineImageXObject, [imgData]);
-        return;
-      }
-      var nativeImageDecoderSupport = this.options.nativeImageDecoderSupport;
-      var objId = 'img_' + this.idFactory.createObjId();
-      operatorList.addDependency(objId);
-      args = [objId, w, h];
-      if (nativeImageDecoderSupport !== _util.NativeImageDecoding.NONE && !softMask && !mask && image instanceof _stream.JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources, this.pdfFunctionFactory)) {
-        operatorList.addOp(_util.OPS.paintJpegXObject, args);
-        this.handler.send('obj', [objId, this.pageIndex, 'JpegStream', image.getIR(this.options.forceDataSchema)]);
-        if (cacheKey) {
-          imageCache[cacheKey] = {
-            fn: _util.OPS.paintJpegXObject,
-            args
-          };
-        }
-        return;
-      }
-      var nativeImageDecoder = null;
-      if (nativeImageDecoderSupport === _util.NativeImageDecoding.DECODE && (image instanceof _stream.JpegStream || mask instanceof _stream.JpegStream || softMask instanceof _stream.JpegStream)) {
-        nativeImageDecoder = new NativeImageDecoder({
-          xref: this.xref,
-          resources,
-          handler: this.handler,
-          forceDataSchema: this.options.forceDataSchema,
-          pdfFunctionFactory: this.pdfFunctionFactory
-        });
-      }
-      _image.PDFImage.buildImage({
-        handler: this.handler,
-        xref: this.xref,
-        res: resources,
-        image,
-        nativeDecoder: nativeImageDecoder,
-        pdfFunctionFactory: this.pdfFunctionFactory
-      }).then(imageObj => {
-        var imgData = imageObj.createImageData(false);
-        this.handler.send('obj', [objId, this.pageIndex, 'Image', imgData], [imgData.data.buffer]);
-      }).catch(reason => {
-        (0, _util.warn)('Unable to decode image: ' + reason);
-        this.handler.send('obj', [objId, this.pageIndex, 'Image', null]);
-      });
-      operatorList.addOp(_util.OPS.paintImageXObject, args);
-      if (cacheKey) {
-        imageCache[cacheKey] = {
-          fn: _util.OPS.paintImageXObject,
-          args
-        };
-      }
-    },
-    handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
-      var smaskContent = smask.get('G');
-      var smaskOptions = {
-        subtype: smask.get('S').name,
-        backdrop: smask.get('BC')
-      };
-      var transferObj = smask.get('TR');
-      if ((0, _function.isPDFFunction)(transferObj)) {
-        let transferFn = this.pdfFunctionFactory.create(transferObj);
-        var transferMap = new Uint8Array(256);
-        var tmp = new Float32Array(1);
-        for (var i = 0; i < 256; i++) {
-          tmp[0] = i / 255;
-          transferFn(tmp, 0, tmp, 0);
-          transferMap[i] = tmp[0] * 255 | 0;
-        }
-        smaskOptions.transferMap = transferMap;
-      }
-      return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
-    },
-    handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
-      let tilingOpList = new OperatorList();
-      let resourcesArray = [patternDict.get('Resources'), resources];
-      let patternResources = _primitives.Dict.merge(this.xref, resourcesArray);
-      return this.getOperatorList({
-        stream: pattern,
-        task,
-        resources: patternResources,
-        operatorList: tilingOpList
-      }).then(function () {
-        return (0, _pattern.getTilingPatternIR)({
-          fnArray: tilingOpList.fnArray,
-          argsArray: tilingOpList.argsArray
-        }, patternDict, args);
-      }).then(function (tilingPatternIR) {
-        operatorList.addDependencies(tilingOpList.dependencies);
-        operatorList.addOp(fn, tilingPatternIR);
-      }, reason => {
-        if (this.options.ignoreErrors) {
-          this.handler.send('UnsupportedFeature', { featureId: _util.UNSUPPORTED_FEATURES.unknown });
-          (0, _util.warn)(`handleTilingType - ignoring pattern: "${reason}".`);
-          return;
-        }
-        throw reason;
-      });
-    },
-    handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
-      var fontName;
-      if (fontArgs) {
-        fontArgs = fontArgs.slice();
-        fontName = fontArgs[0].name;
-      }
-      return this.loadFont(fontName, fontRef, resources).then(translated => {
-        if (!translated.font.isType3Font) {
-          return translated;
-        }
-        return translated.loadType3Data(this, resources, operatorList, task).then(function () {
-          return translated;
-        }).catch(reason => {
-          this.handler.send('UnsupportedFeature', { featureId: _util.UNSUPPORTED_FEATURES.font });
-          return new TranslatedFont('g_font_error', new _fonts.ErrorFont('Type3 font load error: ' + reason), translated.font);
-        });
-      }).then(translated => {
-        state.font = translated.font;
-        translated.send(this.handler);
-        return translated.loadedName;
-      });
-    },
-    handleText: function PartialEvaluator_handleText(chars, state) {
-      var font = state.font;
-      var glyphs = font.charsToGlyphs(chars);
-      var isAddToPathSet = !!(state.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
-      if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
-        var buildPath = fontChar => {
-          if (!font.renderer.hasBuiltPath(fontChar)) {
-            var path = font.renderer.getPathJs(fontChar);
-            this.handler.send('commonobj', [font.loadedName + '_path_' + fontChar, 'FontPath', path]);
-          }
-        };
-        for (var i = 0, ii = glyphs.length; i < ii; i++) {
-          var glyph = glyphs[i];
-          buildPath(glyph.fontChar);
-          var accent = glyph.accent;
-          if (accent && accent.fontChar) {
-            buildPath(accent.fontChar);
-          }
-        }
-      }
-      return glyphs;
-    },
-    setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, stateManager) {
-      var gStateObj = [];
-      var gStateKeys = gState.getKeys();
-      var promise = Promise.resolve();
-      for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
-        let key = gStateKeys[i];
-        let value = gState.get(key);
-        switch (key) {
-          case 'Type':
-            break;
-          case 'LW':
-          case 'LC':
-          case 'LJ':
-          case 'ML':
-          case 'D':
-          case 'RI':
-          case 'FL':
-          case 'CA':
-          case 'ca':
-            gStateObj.push([key, value]);
-            break;
-          case 'Font':
-            promise = promise.then(() => {
-              return this.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
-                operatorList.addDependency(loadedName);
-                gStateObj.push([key, [loadedName, value[1]]]);
-              });
-            });
-            break;
-          case 'BM':
-            gStateObj.push([key, normalizeBlendMode(value)]);
-            break;
-          case 'SMask':
-            if ((0, _primitives.isName)(value, 'None')) {
-              gStateObj.push([key, false]);
-              break;
-            }
-            if ((0, _primitives.isDict)(value)) {
-              promise = promise.then(() => {
-                return this.handleSMask(value, resources, operatorList, task, stateManager);
-              });
-              gStateObj.push([key, true]);
-            } else {
-              (0, _util.warn)('Unsupported SMask type');
-            }
-            break;
-          case 'OP':
-          case 'op':
-          case 'OPM':
-          case 'BG':
-          case 'BG2':
-          case 'UCR':
-          case 'UCR2':
-          case 'TR':
-          case 'TR2':
-          case 'HT':
-          case 'SM':
-          case 'SA':
-          case 'AIS':
-          case 'TK':
-            (0, _util.info)('graphic state operator ' + key);
-            break;
-          default:
-            (0, _util.info)('Unknown graphic state operator ' + key);
-            break;
-        }
-      }
-      return promise.then(function () {
-        if (gStateObj.length > 0) {
-          operatorList.addOp(_util.OPS.setGState, [gStateObj]);
-        }
-      });
-    },
-    loadFont: function PartialEvaluator_loadFont(fontName, font, resources) {
-      function errorFont() {
-        return Promise.resolve(new TranslatedFont('g_font_error', new _fonts.ErrorFont('Font ' + fontName + ' is not available'), font));
-      }
-      var fontRef,
-          xref = this.xref;
-      if (font) {
-        if (!(0, _primitives.isRef)(font)) {
-          throw new Error('The "font" object should be a reference.');
-        }
-        fontRef = font;
-      } else {
-        var fontRes = resources.get('Font');
-        if (fontRes) {
-          fontRef = fontRes.getRaw(fontName);
-        } else {
-          (0, _util.warn)('fontRes not available');
-          return errorFont();
-        }
-      }
-      if (!fontRef) {
-        (0, _util.warn)('fontRef not available');
-        return errorFont();
-      }
-      if (this.fontCache.has(fontRef)) {
-        return this.fontCache.get(fontRef);
-      }
-      font = xref.fetchIfRef(fontRef);
-      if (!(0, _primitives.isDict)(font)) {
-        return errorFont();
-      }
-      if (font.translated) {
-        return font.translated;
-      }
-      var fontCapability = (0, _util.createPromiseCapability)();
-      var preEvaluatedFont = this.preEvaluateFont(font);
-      var descriptor = preEvaluatedFont.descriptor;
-      var fontRefIsRef = (0, _primitives.isRef)(fontRef),
-          fontID;
-      if (fontRefIsRef) {
-        fontID = fontRef.toString();
-      }
-      if ((0, _primitives.isDict)(descriptor)) {
-        if (!descriptor.fontAliases) {
-          descriptor.fontAliases = Object.create(null);
-        }
-        var fontAliases = descriptor.fontAliases;
-        var hash = preEvaluatedFont.hash;
-        if (fontAliases[hash]) {
-          var aliasFontRef = fontAliases[hash].aliasRef;
-          if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
-            this.fontCache.putAlias(fontRef, aliasFontRef);
-            return this.fontCache.get(fontRef);
-          }
-        } else {
-          fontAliases[hash] = { fontID: _fonts.Font.getFontID() };
-        }
-        if (fontRefIsRef) {
-          fontAliases[hash].aliasRef = fontRef;
-        }
-        fontID = fontAliases[hash].fontID;
-      }
-      if (fontRefIsRef) {
-        this.fontCache.put(fontRef, fontCapability.promise);
-      } else {
-        if (!fontID) {
-          fontID = this.idFactory.createObjId();
-        }
-        this.fontCache.put('id_' + fontID, fontCapability.promise);
-      }
-      (0, _util.assert)(fontID, 'The "fontID" must be defined.');
-      font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
-      font.translated = fontCapability.promise;
-      var translatedPromise;
-      try {
-        translatedPromise = this.translateFont(preEvaluatedFont);
-      } catch (e) {
-        translatedPromise = Promise.reject(e);
-      }
-      translatedPromise.then(function (translatedFont) {
-        if (translatedFont.fontType !== undefined) {
-          var xrefFontStats = xref.stats.fontTypes;
-          xrefFontStats[translatedFont.fontType] = true;
-        }
-        fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
-      }).catch(reason => {
-        this.handler.send('UnsupportedFeature', { featureId: _util.UNSUPPORTED_FEATURES.font });
-        try {
-          var descriptor = preEvaluatedFont.descriptor;
-          var fontFile3 = descriptor && descriptor.get('FontFile3');
-          var subtype = fontFile3 && fontFile3.get('Subtype');
-          var fontType = (0, _fonts.getFontType)(preEvaluatedFont.type, subtype && subtype.name);
-          var xrefFontStats = xref.stats.fontTypes;
-          xrefFontStats[fontType] = true;
-        } catch (ex) {}
-        fontCapability.resolve(new TranslatedFont(font.loadedName, new _fonts.ErrorFont(reason instanceof Error ? reason.message : reason), font));
-      });
-      return fontCapability.promise;
-    },
-    buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
-      var lastIndex = operatorList.length - 1;
-      if (!args) {
-        args = [];
-      }
-      if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== _util.OPS.constructPath) {
-        operatorList.addOp(_util.OPS.constructPath, [[fn], args]);
-      } else {
-        var opArgs = operatorList.argsArray[lastIndex];
-        opArgs[0].push(fn);
-        Array.prototype.push.apply(opArgs[1], args);
-      }
-    },
-    handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task) {
-      var patternName = args[args.length - 1];
-      var pattern;
-      if ((0, _primitives.isName)(patternName) && (pattern = patterns.get(patternName.name))) {
-        var dict = (0, _primitives.isStream)(pattern) ? pattern.dict : pattern;
-        var typeNum = dict.get('PatternType');
-        if (typeNum === TILING_PATTERN) {
-          var color = cs.base ? cs.base.getRgb(args, 0) : null;
-          return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
-        } else if (typeNum === SHADING_PATTERN) {
-          var shading = dict.get('Shading');
-          var matrix = dict.getArray('Matrix');
-          pattern = _pattern.Pattern.parseShading(shading, matrix, this.xref, resources, this.handler, this.pdfFunctionFactory);
-          operatorList.addOp(fn, pattern.getIR());
-          return Promise.resolve();
-        }
-        return Promise.reject(new Error('Unknown PatternType: ' + typeNum));
-      }
-      operatorList.addOp(fn, args);
-      return Promise.resolve();
-    },
-    getOperatorList({ stream, task, resources, operatorList, initialState = null }) {
-      resources = resources || _primitives.Dict.empty;
-      initialState = initialState || new EvalState();
-      if (!operatorList) {
-        throw new Error('getOperatorList: missing "operatorList" parameter');
-      }
-      var self = this;
-      var xref = this.xref;
-      var imageCache = Object.create(null);
-      var xobjs = resources.get('XObject') || _primitives.Dict.empty;
-      var patterns = resources.get('Pattern') || _primitives.Dict.empty;
-      var stateManager = new StateManager(initialState);
-      var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
-      var timeSlotManager = new TimeSlotManager();
-      function closePendingRestoreOPS(argument) {
-        for (var i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
-          operatorList.addOp(_util.OPS.restore, []);
-        }
-      }
-      return new Promise(function promiseBody(resolve, reject) {
-        var next = function (promise) {
-          promise.then(function () {
-            try {
-              promiseBody(resolve, reject);
-            } catch (ex) {
-              reject(ex);
-            }
-          }, reject);
-        };
-        task.ensureNotTerminated();
-        timeSlotManager.reset();
-        var stop,
-            operation = {},
-            i,
-            ii,
-            cs;
-        while (!(stop = timeSlotManager.check())) {
-          operation.args = null;
-          if (!preprocessor.read(operation)) {
-            break;
-          }
-          var args = operation.args;
-          var fn = operation.fn;
-          switch (fn | 0) {
-            case _util.OPS.paintXObject:
-              var name = args[0].name;
-              if (name && imageCache[name] !== undefined) {
-                operatorList.addOp(imageCache[name].fn, imageCache[name].args);
-                args = null;
-                continue;
-              }
-              next(new Promise(function (resolveXObject, rejectXObject) {
-                if (!name) {
-                  throw new _util.FormatError('XObject must be referred to by name.');
-                }
-                let xobj = xobjs.get(name);
-                if (!xobj) {
-                  operatorList.addOp(fn, args);
-                  resolveXObject();
-                  return;
-                }
-                if (!(0, _primitives.isStream)(xobj)) {
-                  throw new _util.FormatError('XObject should be a stream');
-                }
-                let type = xobj.dict.get('Subtype');
-                if (!(0, _primitives.isName)(type)) {
-                  throw new _util.FormatError('XObject should have a Name subtype');
-                }
-                if (type.name === 'Form') {
-                  stateManager.save();
-                  self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
-                    stateManager.restore();
-                    resolveXObject();
-                  }, rejectXObject);
-                  return;
-                } else if (type.name === 'Image') {
-                  self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
-                } else if (type.name === 'PS') {
-                  (0, _util.info)('Ignored XObject subtype PS');
-                } else {
-                  throw new _util.FormatError(`Unhandled XObject subtype ${type.name}`);
-                }
-                resolveXObject();
-              }).catch(function (reason) {
-                if (self.options.ignoreErrors) {
-                  self.handler.send('UnsupportedFeature', { featureId: _util.UNSUPPORTED_FEATURES.unknown });
-                  (0, _util.warn)(`getOperatorList - ignoring XObject: "${reason}".`);
-                  return;
-                }
-                throw reason;
-              }));
-              return;
-            case _util.OPS.setFont:
-              var fontSize = args[1];
-              next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
-                operatorList.addDependency(loadedName);
-                operatorList.addOp(_util.OPS.setFont, [loadedName, fontSize]);
-              }));
-              return;
-            case _util.OPS.endInlineImage:
-              var cacheKey = args[0].cacheKey;
-              if (cacheKey) {
-                var cacheEntry = imageCache[cacheKey];
-                if (cacheEntry !== undefined) {
-                  operatorList.addOp(cacheEntry.fn, cacheEntry.args);
-                  args = null;
-                  continue;
-                }
-              }
-              self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
-              args = null;
-              continue;
-            case _util.OPS.showText:
-              args[0] = self.handleText(args[0], stateManager.state);
-              break;
-            case _util.OPS.showSpacedText:
-              var arr = args[0];
-              var combinedGlyphs = [];
-              var arrLength = arr.length;
-              var state = stateManager.state;
-              for (i = 0; i < arrLength; ++i) {
-                var arrItem = arr[i];
-                if ((0, _util.isString)(arrItem)) {
-                  Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
-                } else if ((0, _util.isNum)(arrItem)) {
-                  combinedGlyphs.push(arrItem);
-                }
-              }
-              args[0] = combinedGlyphs;
-              fn = _util.OPS.showText;
-              break;
-            case _util.OPS.nextLineShowText:
-              operatorList.addOp(_util.OPS.nextLine);
-              args[0] = self.handleText(args[0], stateManager.state);
-              fn = _util.OPS.showText;
-              break;
-            case _util.OPS.nextLineSetSpacingShowText:
-              operatorList.addOp(_util.OPS.nextLine);
-              operatorList.addOp(_util.OPS.setWordSpacing, [args.shift()]);
-              operatorList.addOp(_util.OPS.setCharSpacing, [args.shift()]);
-              args[0] = self.handleText(args[0], stateManager.state);
-              fn = _util.OPS.showText;
-              break;
-            case _util.OPS.setTextRenderingMode:
-              stateManager.state.textRenderingMode = args[0];
-              break;
-            case _util.OPS.setFillColorSpace:
-              stateManager.state.fillColorSpace = _colorspace.ColorSpace.parse(args[0], xref, resources, self.pdfFunctionFactory);
-              continue;
-            case _util.OPS.setStrokeColorSpace:
-              stateManager.state.strokeColorSpace = _colorspace.ColorSpace.parse(args[0], xref, resources, self.pdfFunctionFactory);
-              continue;
-            case _util.OPS.setFillColor:
-              cs = stateManager.state.fillColorSpace;
-              args = cs.getRgb(args, 0);
-              fn = _util.OPS.setFillRGBColor;
-              break;
-            case _util.OPS.setStrokeColor:
-              cs = stateManager.state.strokeColorSpace;
-              args = cs.getRgb(args, 0);
-              fn = _util.OPS.setStrokeRGBColor;
-              break;
-            case _util.OPS.setFillGray:
-              stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.gray;
-              args = _colorspace.ColorSpace.singletons.gray.getRgb(args, 0);
-              fn = _util.OPS.setFillRGBColor;
-              break;
-            case _util.OPS.setStrokeGray:
-              stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.gray;
-              args = _colorspace.ColorSpace.singletons.gray.getRgb(args, 0);
-              fn = _util.OPS.setStrokeRGBColor;
-              break;
-            case _util.OPS.setFillCMYKColor:
-              stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.cmyk;
-              args = _colorspace.ColorSpace.singletons.cmyk.getRgb(args, 0);
-              fn = _util.OPS.setFillRGBColor;
-              break;
-            case _util.OPS.setStrokeCMYKColor:
-              stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.cmyk;
-              args = _colorspace.ColorSpace.singletons.cmyk.getRgb(args, 0);
-              fn = _util.OPS.setStrokeRGBColor;
-              break;
-            case _util.OPS.setFillRGBColor:
-              stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.rgb;
-              args = _colorspace.ColorSpace.singletons.rgb.getRgb(args, 0);
-              break;
-            case _util.OPS.setStrokeRGBColor:
-              stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.rgb;
-              args = _colorspace.ColorSpace.singletons.rgb.getRgb(args, 0);
-              break;
-            case _util.OPS.setFillColorN:
-              cs = stateManager.state.fillColorSpace;
-              if (cs.name === 'Pattern') {
-                next(self.handleColorN(operatorList, _util.OPS.setFillColorN, args, cs, patterns, resources, task));
-                return;
-              }
-              args = cs.getRgb(args, 0);
-              fn = _util.OPS.setFillRGBColor;
-              break;
-            case _util.OPS.setStrokeColorN:
-              cs = stateManager.state.strokeColorSpace;
-              if (cs.name === 'Pattern') {
-                next(self.handleColorN(operatorList, _util.OPS.setStrokeColorN, args, cs, patterns, resources, task));
-                return;
-              }
-              args = cs.getRgb(args, 0);
-              fn = _util.OPS.setStrokeRGBColor;
-              break;
-            case _util.OPS.shadingFill:
-              var shadingRes = resources.get('Shading');
-              if (!shadingRes) {
-                throw new _util.FormatError('No shading resource found');
-              }
-              var shading = shadingRes.get(args[0].name);
-              if (!shading) {
-                throw new _util.FormatError('No shading object found');
-              }
-              var shadingFill = _pattern.Pattern.parseShading(shading, null, xref, resources, self.handler, self.pdfFunctionFactory);
-              var patternIR = shadingFill.getIR();
-              args = [patternIR];
-              fn = _util.OPS.shadingFill;
-              break;
-            case _util.OPS.setGState:
-              var dictName = args[0];
-              var extGState = resources.get('ExtGState');
-              if (!(0, _primitives.isDict)(extGState) || !extGState.has(dictName.name)) {
-                break;
-              }
-              var gState = extGState.get(dictName.name);
-              next(self.setGState(resources, gState, operatorList, task, stateManager));
-              return;
-            case _util.OPS.moveTo:
-            case _util.OPS.lineTo:
-            case _util.OPS.curveTo:
-            case _util.OPS.curveTo2:
-            case _util.OPS.curveTo3:
-            case _util.OPS.closePath:
-              self.buildPath(operatorList, fn, args);
-              continue;
-            case _util.OPS.rectangle:
-              self.buildPath(operatorList, fn, args);
-              continue;
-            case _util.OPS.markPoint:
-            case _util.OPS.markPointProps:
-            case _util.OPS.beginMarkedContent:
-            case _util.OPS.beginMarkedContentProps:
-            case _util.OPS.endMarkedContent:
-            case _util.OPS.beginCompat:
-            case _util.OPS.endCompat:
-              continue;
-            default:
-              if (args !== null) {
-                for (i = 0, ii = args.length; i < ii; i++) {
-                  if (args[i] instanceof _primitives.Dict) {
-                    break;
-                  }
-                }
-                if (i < ii) {
-                  (0, _util.warn)('getOperatorList - ignoring operator: ' + fn);
-                  continue;
-                }
-              }
-          }
-          operatorList.addOp(fn, args);
-        }
-        if (stop) {
-          next(deferred);
-          return;
-        }
-        closePendingRestoreOPS();
-        resolve();
-      }).catch(reason => {
-        if (this.options.ignoreErrors) {
-          this.handler.send('UnsupportedFeature', { featureId: _util.UNSUPPORTED_FEATURES.unknown });
-          (0, _util.warn)('getOperatorList - ignoring errors during task: ' + task.name);
-          closePendingRestoreOPS();
-          return;
-        }
-        throw reason;
-      });
-    },
-    getTextContent({ stream, task, resources, stateManager = null, normalizeWhitespace = false, combineTextItems = false, sink, seenStyles = Object.create(null) }) {
-      resources = resources || _primitives.Dict.empty;
-      stateManager = stateManager || new StateManager(new TextState());
-      var WhitespaceRegexp = /\s/g;
-      var textContent = {
-        items: [],
-        styles: Object.create(null)
-      };
-      var textContentItem = {
-        initialized: false,
-        str: [],
-        width: 0,
-        height: 0,
-        vertical: false,
-        lastAdvanceWidth: 0,
-        lastAdvanceHeight: 0,
-        textAdvanceScale: 0,
-        spaceWidth: 0,
-        fakeSpaceMin: Infinity,
-        fakeMultiSpaceMin: Infinity,
-        fakeMultiSpaceMax: -0,
-        textRunBreakAllowed: false,
-        transform: null,
-        fontName: null
-      };
-      var SPACE_FACTOR = 0.3;
-      var MULTI_SPACE_FACTOR = 1.5;
-      var MULTI_SPACE_FACTOR_MAX = 4;
-      var self = this;
-      var xref = this.xref;
-      var xobjs = null;
-      var skipEmptyXObjs = Object.create(null);
-      var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
-      var textState;
-      function ensureTextContentItem() {
-        if (textContentItem.initialized) {
-          return textContentItem;
-        }
-        var font = textState.font;
-        if (!(font.loadedName in seenStyles)) {
-          seenStyles[font.loadedName] = true;
-          textContent.styles[font.loadedName] = {
-            fontFamily: font.fallbackName,
-            ascent: font.ascent,
-            descent: font.descent,
-            vertical: font.vertical
-          };
-        }
-        textContentItem.fontName = font.loadedName;
-        var tsm = [textState.fontSize * textState.textHScale, 0, 0, textState.fontSize, 0, textState.textRise];
-        if (font.isType3Font && textState.fontMatrix !== _util.FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
-          var glyphHeight = font.bbox[3] - font.bbox[1];
-          if (glyphHeight > 0) {
-            glyphHeight = glyphHeight * textState.fontMatrix[3];
-            tsm[3] *= glyphHeight;
-          }
-        }
-        var trm = _util.Util.transform(textState.ctm, _util.Util.transform(textState.textMatrix, tsm));
-        textContentItem.transform = trm;
-        if (!font.vertical) {
-          textContentItem.width = 0;
-          textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
-          textContentItem.vertical = false;
-        } else {
-          textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
-          textContentItem.height = 0;
-          textContentItem.vertical = true;
-        }
-        var a = textState.textLineMatrix[0];
-        var b = textState.textLineMatrix[1];
-        var scaleLineX = Math.sqrt(a * a + b * b);
-        a = textState.ctm[0];
-        b = textState.ctm[1];
-        var scaleCtmX = Math.sqrt(a * a + b * b);
-        textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
-        textContentItem.lastAdvanceWidth = 0;
-        textContentItem.lastAdvanceHeight = 0;
-        var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
-        if (spaceWidth) {
-          textContentItem.spaceWidth = spaceWidth;
-          textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
-          textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
-          textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
-          textContentItem.textRunBreakAllowed = !font.isMonospace;
-        } else {
-          textContentItem.spaceWidth = 0;
-          textContentItem.fakeSpaceMin = Infinity;
-          textContentItem.fakeMultiSpaceMin = Infinity;
-          textContentItem.fakeMultiSpaceMax = 0;
-          textContentItem.textRunBreakAllowed = false;
-        }
-        textContentItem.initialized = true;
-        return textContentItem;
-      }
-      function replaceWhitespace(str) {
-        var i = 0,
-            ii = str.length,
-            code;
-        while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
-          i++;
-        }
-        return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
-      }
-      function runBidiTransform(textChunk) {
-        var str = textChunk.str.join('');
-        var bidiResult = (0, _bidi.bidi)(str, -1, textChunk.vertical);
-        return {
-          str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
-          dir: bidiResult.dir,
-          width: textChunk.width,
-          height: textChunk.height,
-          transform: textChunk.transform,
-          fontName: textChunk.fontName
-        };
-      }
-      function handleSetFont(fontName, fontRef) {
-        return self.loadFont(fontName, fontRef, resources).then(function (translated) {
-          textState.font = translated.font;
-          textState.fontMatrix = translated.font.fontMatrix || _util.FONT_IDENTITY_MATRIX;
-        });
-      }
-      function buildTextContentItem(chars) {
-        var font = textState.font;
-        var textChunk = ensureTextContentItem();
-        var width = 0;
-        var height = 0;
-        var glyphs = font.charsToGlyphs(chars);
-        for (var i = 0; i < glyphs.length; i++) {
-          var glyph = glyphs[i];
-          var glyphWidth = null;
-          if (font.vertical && glyph.vmetric) {
-            glyphWidth = glyph.vmetric[0];
-          } else {
-            glyphWidth = glyph.width;
-          }
-          var glyphUnicode = glyph.unicode;
-          var NormalizedUnicodes = (0, _unicode.getNormalizedUnicodes)();
-          if (NormalizedUnicodes[glyphUnicode] !== undefined) {
-            glyphUnicode = NormalizedUnicodes[glyphUnicode];
-          }
-          glyphUnicode = (0, _unicode.reverseIfRtl)(glyphUnicode);
-          var charSpacing = textState.charSpacing;
-          if (glyph.isSpace) {
-            var wordSpacing = textState.wordSpacing;
-            charSpacing += wordSpacing;
-            if (wordSpacing > 0) {
-              addFakeSpaces(wordSpacing, textChunk.str);
-            }
-          }
-          var tx = 0;
-          var ty = 0;
-          if (!font.vertical) {
-            var w0 = glyphWidth * textState.fontMatrix[0];
-            tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
-            width += tx;
-          } else {
-            var w1 = glyphWidth * textState.fontMatrix[0];
-            ty = w1 * textState.fontSize + charSpacing;
-            height += ty;
-          }
-          textState.translateTextMatrix(tx, ty);
-          textChunk.str.push(glyphUnicode);
-        }
-        if (!font.vertical) {
-          textChunk.lastAdvanceWidth = width;
-          textChunk.width += width;
-        } else {
-          textChunk.lastAdvanceHeight = height;
-          textChunk.height += Math.abs(height);
-        }
-        return textChunk;
-      }
-      function addFakeSpaces(width, strBuf) {
-        if (width < textContentItem.fakeSpaceMin) {
-          return;
-        }
-        if (width < textContentItem.fakeMultiSpaceMin) {
-          strBuf.push(' ');
-          return;
-        }
-        var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
-        while (fakeSpaces-- > 0) {
-          strBuf.push(' ');
-        }
-      }
-      function flushTextContentItem() {
-        if (!textContentItem.initialized) {
-          return;
-        }
-        textContentItem.width *= textContentItem.textAdvanceScale;
-        textContentItem.height *= textContentItem.textAdvanceScale;
-        textContent.items.push(runBidiTransform(textContentItem));
-        textContentItem.initialized = false;
-        textContentItem.str.length = 0;
-      }
-      function enqueueChunk() {
-        let length = textContent.items.length;
-        if (length > 0) {
-          sink.enqueue(textContent, length);
-          textContent.items = [];
-          textContent.styles = Object.create(null);
-        }
-      }
-      var timeSlotManager = new TimeSlotManager();
-      return new Promise(function promiseBody(resolve, reject) {
-        let next = function (promise) {
-          enqueueChunk();
-          Promise.all([promise, sink.ready]).then(function () {
-            try {
-              promiseBody(resolve, reject);
-            } catch (ex) {
-              reject(ex);
-            }
-          }, reject);
-        };
-        task.ensureNotTerminated();
-        timeSlotManager.reset();
-        var stop,
-            operation = {},
-            args = [];
-        while (!(stop = timeSlotManager.check())) {
-          args.length = 0;
-          operation.args = args;
-          if (!preprocessor.read(operation)) {
-            break;
-          }
-          textState = stateManager.state;
-          var fn = operation.fn;
-          args = operation.args;
-          var advance, diff;
-          switch (fn | 0) {
-            case _util.OPS.setFont:
-              var fontNameArg = args[0].name,
-                  fontSizeArg = args[1];
-              if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
-                break;
-              }
-              flushTextContentItem();
-              textState.fontName = fontNameArg;
-              textState.fontSize = fontSizeArg;
-              next(handleSetFont(fontNameArg, null));
-              return;
-            case _util.OPS.setTextRise:
-              flushTextContentItem();
-              textState.textRise = args[0];
-              break;
-            case _util.OPS.setHScale:
-              flushTextContentItem();
-              textState.textHScale = args[0] / 100;
-              break;
-            case _util.OPS.setLeading:
-              flushTextContentItem();
-              textState.leading = args[0];
-              break;
-            case _util.OPS.moveText:
-              var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
-              advance = args[0] - args[1];
-              if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
-                textState.translateTextLineMatrix(args[0], args[1]);
-                textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
-                textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
-                diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
-                addFakeSpaces(diff, textContentItem.str);
-                break;
-              }
-              flushTextContentItem();
-              textState.translateTextLineMatrix(args[0], args[1]);
-              textState.textMatrix = textState.textLineMatrix.slice();
-              break;
-            case _util.OPS.setLeadingMoveText:
-              flushTextContentItem();
-              textState.leading = -args[1];
-              textState.translateTextLineMatrix(args[0], args[1]);
-              textState.textMatrix = textState.textLineMatrix.slice();
-              break;
-            case _util.OPS.nextLine:
-              flushTextContentItem();
-              textState.carriageReturn();
-              break;
-            case _util.OPS.setTextMatrix:
-              advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
-              if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
-                textState.translateTextLineMatrix(advance.width, advance.height);
-                textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
-                textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
-                diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
-                addFakeSpaces(diff, textContentItem.str);
-                break;
-              }
-              flushTextContentItem();
-              textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
-              textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
-              break;
-            case _util.OPS.setCharSpacing:
-              textState.charSpacing = args[0];
-              break;
-            case _util.OPS.setWordSpacing:
-              textState.wordSpacing = args[0];
-              break;
-            case _util.OPS.beginText:
-              flushTextContentItem();
-              textState.textMatrix = _util.IDENTITY_MATRIX.slice();
-              textState.textLineMatrix = _util.IDENTITY_MATRIX.slice();
-              break;
-            case _util.OPS.showSpacedText:
-              var items = args[0];
-              var offset;
-              for (var j = 0, jj = items.length; j < jj; j++) {
-                if (typeof items[j] === 'string') {
-                  buildTextContentItem(items[j]);
-                } else if ((0, _util.isNum)(items[j])) {
-                  ensureTextContentItem();
-                  advance = items[j] * textState.fontSize / 1000;
-                  var breakTextRun = false;
-                  if (textState.font.vertical) {
-                    offset = advance;
-                    textState.translateTextMatrix(0, offset);
-                    breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
-                    if (!breakTextRun) {
-                      textContentItem.height += offset;
-                    }
-                  } else {
-                    advance = -advance;
-                    offset = advance * textState.textHScale;
-                    textState.translateTextMatrix(offset, 0);
-                    breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
-                    if (!breakTextRun) {
-                      textContentItem.width += offset;
-                    }
-                  }
-                  if (breakTextRun) {
-                    flushTextContentItem();
-                  } else if (advance > 0) {
-                    addFakeSpaces(advance, textContentItem.str);
-                  }
-                }
-              }
-              break;
-            case _util.OPS.showText:
-              buildTextContentItem(args[0]);
-              break;
-            case _util.OPS.nextLineShowText:
-              flushTextContentItem();
-              textState.carriageReturn();
-              buildTextContentItem(args[0]);
-              break;
-            case _util.OPS.nextLineSetSpacingShowText:
-              flushTextContentItem();
-              textState.wordSpacing = args[0];
-              textState.charSpacing = args[1];
-              textState.carriageReturn();
-              buildTextContentItem(args[2]);
-              break;
-            case _util.OPS.paintXObject:
-              flushTextContentItem();
-              if (!xobjs) {
-                xobjs = resources.get('XObject') || _primitives.Dict.empty;
-              }
-              var name = args[0].name;
-              if (name && skipEmptyXObjs[name] !== undefined) {
-                break;
-              }
-              next(new Promise(function (resolveXObject, rejectXObject) {
-                if (!name) {
-                  throw new _util.FormatError('XObject must be referred to by name.');
-                }
-                let xobj = xobjs.get(name);
-                if (!xobj) {
-                  resolveXObject();
-                  return;
-                }
-                if (!(0, _primitives.isStream)(xobj)) {
-                  throw new _util.FormatError('XObject should be a stream');
-                }
-                let type = xobj.dict.get('Subtype');
-                if (!(0, _primitives.isName)(type)) {
-                  throw new _util.FormatError('XObject should have a Name subtype');
-                }
-                if (type.name !== 'Form') {
-                  skipEmptyXObjs[name] = true;
-                  resolveXObject();
-                  return;
-                }
-                let currentState = stateManager.state.clone();
-                let xObjStateManager = new StateManager(currentState);
-                let matrix = xobj.dict.getArray('Matrix');
-                if (Array.isArray(matrix) && matrix.length === 6) {
-                  xObjStateManager.transform(matrix);
-                }
-                enqueueChunk();
-                let sinkWrapper = {
-                  enqueueInvoked: false,
-                  enqueue(chunk, size) {
-                    this.enqueueInvoked = true;
-                    sink.enqueue(chunk, size);
-                  },
-                  get desiredSize() {
-                    return sink.desiredSize;
-                  },
-                  get ready() {
-                    return sink.ready;
-                  }
-                };
-                self.getTextContent({
-                  stream: xobj,
-                  task,
-                  resources: xobj.dict.get('Resources') || resources,
-                  stateManager: xObjStateManager,
-                  normalizeWhitespace,
-                  combineTextItems,
-                  sink: sinkWrapper,
-                  seenStyles
-                }).then(function () {
-                  if (!sinkWrapper.enqueueInvoked) {
-                    skipEmptyXObjs[name] = true;
-                  }
-                  resolveXObject();
-                }, rejectXObject);
-              }).catch(function (reason) {
-                if (reason instanceof _util.AbortException) {
-                  return;
-                }
-                if (self.options.ignoreErrors) {
-                  (0, _util.warn)(`getTextContent - ignoring XObject: "${reason}".`);
-                  return;
-                }
-                throw reason;
-              }));
-              return;
-            case _util.OPS.setGState:
-              flushTextContentItem();
-              var dictName = args[0];
-              var extGState = resources.get('ExtGState');
-              if (!(0, _primitives.isDict)(extGState) || !(0, _primitives.isName)(dictName)) {
-                break;
-              }
-              var gState = extGState.get(dictName.name);
-              if (!(0, _primitives.isDict)(gState)) {
-                break;
-              }
-              var gStateFont = gState.get('Font');
-              if (gStateFont) {
-                textState.fontName = null;
-                textState.fontSize = gStateFont[1];
-                next(handleSetFont(null, gStateFont[0]));
-                return;
-              }
-              break;
-          }
-          if (textContent.items.length >= sink.desiredSize) {
-            stop = true;
-            break;
-          }
-        }
-        if (stop) {
-          next(deferred);
-          return;
-        }
-        flushTextContentItem();
-        enqueueChunk();
-        resolve();
-      }).catch(reason => {
-        if (reason instanceof _util.AbortException) {
-          return;
-        }
-        if (this.options.ignoreErrors) {
-          (0, _util.warn)('getTextContent - ignoring errors during task: ' + task.name);
-          flushTextContentItem();
-          enqueueChunk();
-          return;
-        }
-        throw reason;
-      });
-    },
-    extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, properties) {
-      var xref = this.xref;
-      var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
-      var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
-      if (properties.composite) {
-        var cidSystemInfo = dict.get('CIDSystemInfo');
-        if ((0, _primitives.isDict)(cidSystemInfo)) {
-          properties.cidSystemInfo = {
-            registry: cidSystemInfo.get('Registry'),
-            ordering: cidSystemInfo.get('Ordering'),
-            supplement: cidSystemInfo.get('Supplement')
-          };
-        }
-        var cidToGidMap = dict.get('CIDToGIDMap');
-        if ((0, _primitives.isStream)(cidToGidMap)) {
-          properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
-        }
-      }
-      var differences = [];
-      var baseEncodingName = null;
-      var encoding;
-      if (dict.has('Encoding')) {
-        encoding = dict.get('Encoding');
-        if ((0, _primitives.isDict)(encoding)) {
-          baseEncodingName = encoding.get('BaseEncoding');
-          baseEncodingName = (0, _primitives.isName)(baseEncodingName) ? baseEncodingName.name : null;
-          if (encoding.has('Differences')) {
-            var diffEncoding = encoding.get('Differences');
-            var index = 0;
-            for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
-              var data = xref.fetchIfRef(diffEncoding[j]);
-              if ((0, _util.isNum)(data)) {
-                index = data;
-              } else if ((0, _primitives.isName)(data)) {
-                differences[index++] = data.name;
-              } else {
-                throw new _util.FormatError(`Invalid entry in 'Differences' array: ${data}`);
-              }
-            }
-          }
-        } else if ((0, _primitives.isName)(encoding)) {
-          baseEncodingName = encoding.name;
-        } else {
-          throw new _util.FormatError('Encoding is not a Name nor a Dict');
-        }
-        if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
-          baseEncodingName = null;
-        }
-      }
-      if (baseEncodingName) {
-        properties.defaultEncoding = (0, _encodings.getEncoding)(baseEncodingName).slice();
-      } else {
-        var isSymbolicFont = !!(properties.flags & _fonts.FontFlags.Symbolic);
-        var isNonsymbolicFont = !!(properties.flags & _fonts.FontFlags.Nonsymbolic);
-        encoding = _encodings.StandardEncoding;
-        if (properties.type === 'TrueType' && !isNonsymbolicFont) {
-          encoding = _encodings.WinAnsiEncoding;
-        }
-        if (isSymbolicFont) {
-          encoding = _encodings.MacRomanEncoding;
-          if (!properties.file) {
-            if (/Symbol/i.test(properties.name)) {
-              encoding = _encodings.SymbolSetEncoding;
-            } else if (/Dingbats/i.test(properties.name)) {
-              encoding = _encodings.ZapfDingbatsEncoding;
-            }
-          }
-        }
-        properties.defaultEncoding = encoding;
-      }
-      properties.differences = differences;
-      properties.baseEncodingName = baseEncodingName;
-      properties.hasEncoding = !!baseEncodingName || differences.length > 0;
-      properties.dict = dict;
-      return toUnicodePromise.then(toUnicode => {
-        properties.toUnicode = toUnicode;
-        return this.buildToUnicode(properties);
-      }).then(function (toUnicode) {
-        properties.toUnicode = toUnicode;
-        return properties;
-      });
-    },
-    buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
-      properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
-      if (properties.hasIncludedToUnicodeMap) {
-        return Promise.resolve(properties.toUnicode);
-      }
-      var toUnicode, charcode, glyphName;
-      if (!properties.composite) {
-        toUnicode = [];
-        var encoding = properties.defaultEncoding.slice();
-        var baseEncodingName = properties.baseEncodingName;
-        var differences = properties.differences;
-        for (charcode in differences) {
-          glyphName = differences[charcode];
-          if (glyphName === '.notdef') {
-            continue;
-          }
-          encoding[charcode] = glyphName;
-        }
-        var glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
-        for (charcode in encoding) {
-          glyphName = encoding[charcode];
-          if (glyphName === '') {
-            continue;
-          } else if (glyphsUnicodeMap[glyphName] === undefined) {
-            var code = 0;
-            switch (glyphName[0]) {
-              case 'G':
-                if (glyphName.length === 3) {
-                  code = parseInt(glyphName.substr(1), 16);
-                }
-                break;
-              case 'g':
-                if (glyphName.length === 5) {
-                  code = parseInt(glyphName.substr(1), 16);
-                }
-                break;
-              case 'C':
-              case 'c':
-                if (glyphName.length >= 3) {
-                  code = +glyphName.substr(1);
-                }
-                break;
-              default:
-                var unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
-                if (unicode !== -1) {
-                  code = unicode;
-                }
-            }
-            if (code) {
-              if (baseEncodingName && code === +charcode) {
-                var baseEncoding = (0, _encodings.getEncoding)(baseEncodingName);
-                if (baseEncoding && (glyphName = baseEncoding[charcode])) {
-                  toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
-                  continue;
-                }
-              }
-              toUnicode[charcode] = String.fromCharCode(code);
-            }
-            continue;
-          }
-          toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
-        }
-        return Promise.resolve(new _fonts.ToUnicodeMap(toUnicode));
-      }
-      if (properties.composite && (properties.cMap.builtInCMap && !(properties.cMap instanceof _cmap.IdentityCMap) || properties.cidSystemInfo.registry === 'Adobe' && (properties.cidSystemInfo.ordering === 'GB1' || properties.cidSystemInfo.ordering === 'CNS1' || properties.cidSystemInfo.ordering === 'Japan1' || properties.cidSystemInfo.ordering === 'Korea1'))) {
-        var registry = properties.cidSystemInfo.registry;
-        var ordering = properties.cidSystemInfo.ordering;
-        var ucs2CMapName = _primitives.Name.get(registry + '-' + ordering + '-UCS2');
-        return _cmap.CMapFactory.create({
-          encoding: ucs2CMapName,
-          fetchBuiltInCMap: this.fetchBuiltInCMap,
-          useCMap: null
-        }).then(function (ucs2CMap) {
-          var cMap = properties.cMap;
-          toUnicode = [];
-          cMap.forEach(function (charcode, cid) {
-            if (cid > 0xffff) {
-              throw new _util.FormatError('Max size of CID is 65,535');
-            }
-            var ucs2 = ucs2CMap.lookup(cid);
-            if (ucs2) {
-              toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
-            }
-          });
-          return new _fonts.ToUnicodeMap(toUnicode);
-        });
-      }
-      return Promise.resolve(new _fonts.IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
-    },
-    readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
-      var cmapObj = toUnicode;
-      if ((0, _primitives.isName)(cmapObj)) {
-        return _cmap.CMapFactory.create({
-          encoding: cmapObj,
-          fetchBuiltInCMap: this.fetchBuiltInCMap,
-          useCMap: null
-        }).then(function (cmap) {
-          if (cmap instanceof _cmap.IdentityCMap) {
-            return new _fonts.IdentityToUnicodeMap(0, 0xFFFF);
-          }
-          return new _fonts.ToUnicodeMap(cmap.getMap());
-        });
-      } else if ((0, _primitives.isStream)(cmapObj)) {
-        return _cmap.CMapFactory.create({
-          encoding: cmapObj,
-          fetchBuiltInCMap: this.fetchBuiltInCMap,
-          useCMap: null
-        }).then(function (cmap) {
-          if (cmap instanceof _cmap.IdentityCMap) {
-            return new _fonts.IdentityToUnicodeMap(0, 0xFFFF);
-          }
-          var map = new Array(cmap.length);
-          cmap.forEach(function (charCode, token) {
-            var str = [];
-            for (var k = 0; k < token.length; k += 2) {
-              var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
-              if ((w1 & 0xF800) !== 0xD800) {
-                str.push(w1);
-                continue;
-              }
-              k += 2;
-              var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
-              str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
-            }
-            map[charCode] = String.fromCharCode.apply(String, str);
-          });
-          return new _fonts.ToUnicodeMap(map);
-        });
-      }
-      return Promise.resolve(null);
-    },
-    readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
-      var glyphsData = cidToGidStream.getBytes();
-      var result = [];
-      for (var j = 0, jj = glyphsData.length; j < jj; j++) {
-        var glyphID = glyphsData[j++] << 8 | glyphsData[j];
-        if (glyphID === 0) {
-          continue;
-        }
-        var code = j >> 1;
-        result[code] = glyphID;
-      }
-      return result;
-    },
-    extractWidths: function PartialEvaluator_extractWidths(dict, descriptor, properties) {
-      var xref = this.xref;
-      var glyphsWidths = [];
-      var defaultWidth = 0;
-      var glyphsVMetrics = [];
-      var defaultVMetrics;
-      var i, ii, j, jj, start, code, widths;
-      if (properties.composite) {
-        defaultWidth = dict.has('DW') ? dict.get('DW') : 1000;
-        widths = dict.get('W');
-        if (widths) {
-          for (i = 0, ii = widths.length; i < ii; i++) {
-            start = xref.fetchIfRef(widths[i++]);
-            code = xref.fetchIfRef(widths[i]);
-            if (Array.isArray(code)) {
-              for (j = 0, jj = code.length; j < jj; j++) {
-                glyphsWidths[start++] = xref.fetchIfRef(code[j]);
-              }
-            } else {
-              var width = xref.fetchIfRef(widths[++i]);
-              for (j = start; j <= code; j++) {
-                glyphsWidths[j] = width;
-              }
-            }
-          }
-        }
-        if (properties.vertical) {
-          var vmetrics = dict.getArray('DW2') || [880, -1000];
-          defaultVMetrics = [vmetrics[1], defaultWidth * 0.5, vmetrics[0]];
-          vmetrics = dict.get('W2');
-          if (vmetrics) {
-            for (i = 0, ii = vmetrics.length; i < ii; i++) {
-              start = xref.fetchIfRef(vmetrics[i++]);
-              code = xref.fetchIfRef(vmetrics[i]);
-              if (Array.isArray(code)) {
-                for (j = 0, jj = code.length; j < jj; j++) {
-                  glyphsVMetrics[start++] = [xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j])];
-                }
-              } else {
-                var vmetric = [xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i])];
-                for (j = start; j <= code; j++) {
-                  glyphsVMetrics[j] = vmetric;
-                }
-              }
-            }
-          }
-        }
-      } else {
-        var firstChar = properties.firstChar;
-        widths = dict.get('Widths');
-        if (widths) {
-          j = firstChar;
-          for (i = 0, ii = widths.length; i < ii; i++) {
-            glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
-          }
-          defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
-        } else {
-          var baseFontName = dict.get('BaseFont');
-          if ((0, _primitives.isName)(baseFontName)) {
-            var metrics = this.getBaseFontMetrics(baseFontName.name);
-            glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
-            defaultWidth = metrics.defaultWidth;
-          }
-        }
-      }
-      var isMonospace = true;
-      var firstWidth = defaultWidth;
-      for (var glyph in glyphsWidths) {
-        var glyphWidth = glyphsWidths[glyph];
-        if (!glyphWidth) {
-          continue;
-        }
-        if (!firstWidth) {
-          firstWidth = glyphWidth;
-          continue;
-        }
-        if (firstWidth !== glyphWidth) {
-          isMonospace = false;
-          break;
-        }
-      }
-      if (isMonospace) {
-        properties.flags |= _fonts.FontFlags.FixedPitch;
-      }
-      properties.defaultWidth = defaultWidth;
-      properties.widths = glyphsWidths;
-      properties.defaultVMetrics = defaultVMetrics;
-      properties.vmetrics = glyphsVMetrics;
-    },
-    isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
-      var fontNameWoStyle = baseFontName.split('-')[0];
-      return fontNameWoStyle in (0, _standard_fonts.getSerifFonts)() || fontNameWoStyle.search(/serif/gi) !== -1;
-    },
-    getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
-      var defaultWidth = 0;
-      var widths = [];
-      var monospace = false;
-      var stdFontMap = (0, _standard_fonts.getStdFontMap)();
-      var lookupName = stdFontMap[name] || name;
-      var Metrics = (0, _metrics.getMetrics)();
-      if (!(lookupName in Metrics)) {
-        if (this.isSerifFont(name)) {
-          lookupName = 'Times-Roman';
-        } else {
-          lookupName = 'Helvetica';
-        }
-      }
-      var glyphWidths = Metrics[lookupName];
-      if ((0, _util.isNum)(glyphWidths)) {
-        defaultWidth = glyphWidths;
-        monospace = true;
-      } else {
-        widths = glyphWidths();
-      }
-      return {
-        defaultWidth,
-        monospace,
-        widths
-      };
-    },
-    buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
-      var widths = Object.create(null);
-      var differences = properties.differences;
-      var encoding = properties.defaultEncoding;
-      for (var charCode = 0; charCode < 256; charCode++) {
-        if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
-          widths[charCode] = widthsByGlyphName[differences[charCode]];
-          continue;
-        }
-        if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
-          widths[charCode] = widthsByGlyphName[encoding[charCode]];
-          continue;
-        }
-      }
-      return widths;
-    },
-    preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict) {
-      var baseDict = dict;
-      var type = dict.get('Subtype');
-      if (!(0, _primitives.isName)(type)) {
-        throw new _util.FormatError('invalid font Subtype');
-      }
-      var composite = false;
-      var uint8array;
-      if (type.name === 'Type0') {
-        var df = dict.get('DescendantFonts');
-        if (!df) {
-          throw new _util.FormatError('Descendant fonts are not specified');
-        }
-        dict = Array.isArray(df) ? this.xref.fetchIfRef(df[0]) : df;
-        type = dict.get('Subtype');
-        if (!(0, _primitives.isName)(type)) {
-          throw new _util.FormatError('invalid font Subtype');
-        }
-        composite = true;
-      }
-      var descriptor = dict.get('FontDescriptor');
-      if (descriptor) {
-        var hash = new _murmurhash.MurmurHash3_64();
-        var encoding = baseDict.getRaw('Encoding');
-        if ((0, _primitives.isName)(encoding)) {
-          hash.update(encoding.name);
-        } else if ((0, _primitives.isRef)(encoding)) {
-          hash.update(encoding.toString());
-        } else if ((0, _primitives.isDict)(encoding)) {
-          var keys = encoding.getKeys();
-          for (var i = 0, ii = keys.length; i < ii; i++) {
-            var entry = encoding.getRaw(keys[i]);
-            if ((0, _primitives.isName)(entry)) {
-              hash.update(entry.name);
-            } else if ((0, _primitives.isRef)(entry)) {
-              hash.update(entry.toString());
-            } else if (Array.isArray(entry)) {
-              var diffLength = entry.length,
-                  diffBuf = new Array(diffLength);
-              for (var j = 0; j < diffLength; j++) {
-                var diffEntry = entry[j];
-                if ((0, _primitives.isName)(diffEntry)) {
-                  diffBuf[j] = diffEntry.name;
-                } else if ((0, _util.isNum)(diffEntry) || (0, _primitives.isRef)(diffEntry)) {
-                  diffBuf[j] = diffEntry.toString();
-                }
-              }
-              hash.update(diffBuf.join());
-            }
-          }
-        }
-        var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
-        if ((0, _primitives.isStream)(toUnicode)) {
-          var stream = toUnicode.str || toUnicode;
-          uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
-          hash.update(uint8array);
-        } else if ((0, _primitives.isName)(toUnicode)) {
-          hash.update(toUnicode.name);
-        }
-        var widths = dict.get('Widths') || baseDict.get('Widths');
-        if (widths) {
-          uint8array = new Uint8Array(new Uint32Array(widths).buffer);
-          hash.update(uint8array);
-        }
-      }
-      return {
-        descriptor,
-        dict,
-        baseDict,
-        composite,
-        type: type.name,
-        hash: hash ? hash.hexdigest() : ''
-      };
-    },
-    translateFont: function PartialEvaluator_translateFont(preEvaluatedFont) {
-      var baseDict = preEvaluatedFont.baseDict;
-      var dict = preEvaluatedFont.dict;
-      var composite = preEvaluatedFont.composite;
-      var descriptor = preEvaluatedFont.descriptor;
-      var type = preEvaluatedFont.type;
-      var maxCharIndex = composite ? 0xFFFF : 0xFF;
-      var properties;
-      if (!descriptor) {
-        if (type === 'Type3') {
-          descriptor = new _primitives.Dict(null);
-          descriptor.set('FontName', _primitives.Name.get(type));
-          descriptor.set('FontBBox', dict.getArray('FontBBox'));
-        } else {
-          var baseFontName = dict.get('BaseFont');
-          if (!(0, _primitives.isName)(baseFontName)) {
-            throw new _util.FormatError('Base font is not specified');
-          }
-          baseFontName = baseFontName.name.replace(/[,_]/g, '-');
-          var metrics = this.getBaseFontMetrics(baseFontName);
-          var fontNameWoStyle = baseFontName.split('-')[0];
-          var flags = (this.isSerifFont(fontNameWoStyle) ? _fonts.FontFlags.Serif : 0) | (metrics.monospace ? _fonts.FontFlags.FixedPitch : 0) | ((0, _standard_fonts.getSymbolsFonts)()[fontNameWoStyle] ? _fonts.FontFlags.Symbolic : _fonts.FontFlags.Nonsymbolic);
-          properties = {
-            type,
-            name: baseFontName,
-            widths: metrics.widths,
-            defaultWidth: metrics.defaultWidth,
-            flags,
-            firstChar: 0,
-            lastChar: maxCharIndex
-          };
-          return this.extractDataStructures(dict, dict, properties).then(properties => {
-            properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
-            return new _fonts.Font(baseFontName, null, properties);
-          });
-        }
-      }
-      var firstChar = dict.get('FirstChar') || 0;
-      var lastChar = dict.get('LastChar') || maxCharIndex;
-      var fontName = descriptor.get('FontName');
-      var baseFont = dict.get('BaseFont');
-      if ((0, _util.isString)(fontName)) {
-        fontName = _primitives.Name.get(fontName);
-      }
-      if ((0, _util.isString)(baseFont)) {
-        baseFont = _primitives.Name.get(baseFont);
-      }
-      if (type !== 'Type3') {
-        var fontNameStr = fontName && fontName.name;
-        var baseFontStr = baseFont && baseFont.name;
-        if (fontNameStr !== baseFontStr) {
-          (0, _util.info)('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
-          if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
-            fontName = baseFont;
-          }
-        }
-      }
-      fontName = fontName || baseFont;
-      if (!(0, _primitives.isName)(fontName)) {
-        throw new _util.FormatError('invalid font name');
-      }
-      var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
-      if (fontFile) {
-        if (fontFile.dict) {
-          var subtype = fontFile.dict.get('Subtype');
-          if (subtype) {
-            subtype = subtype.name;
-          }
-          var length1 = fontFile.dict.get('Length1');
-          var length2 = fontFile.dict.get('Length2');
-          var length3 = fontFile.dict.get('Length3');
-        }
-      }
-      properties = {
-        type,
-        name: fontName.name,
-        subtype,
-        file: fontFile,
-        length1,
-        length2,
-        length3,
-        loadedName: baseDict.loadedName,
-        composite,
-        wideChars: composite,
-        fixedPitch: false,
-        fontMatrix: dict.getArray('FontMatrix') || _util.FONT_IDENTITY_MATRIX,
-        firstChar: firstChar || 0,
-        lastChar: lastChar || maxCharIndex,
-        bbox: descriptor.getArray('FontBBox'),
-        ascent: descriptor.get('Ascent'),
-        descent: descriptor.get('Descent'),
-        xHeight: descriptor.get('XHeight'),
-        capHeight: descriptor.get('CapHeight'),
-        flags: descriptor.get('Flags'),
-        italicAngle: descriptor.get('ItalicAngle'),
-        isType3Font: false
-      };
-      var cMapPromise;
-      if (composite) {
-        var cidEncoding = baseDict.get('Encoding');
-        if ((0, _primitives.isName)(cidEncoding)) {
-          properties.cidEncoding = cidEncoding.name;
-        }
-        cMapPromise = _cmap.CMapFactory.create({
-          encoding: cidEncoding,
-          fetchBuiltInCMap: this.fetchBuiltInCMap,
-          useCMap: null
-        }).then(function (cMap) {
-          properties.cMap = cMap;
-          properties.vertical = properties.cMap.vertical;
-        });
-      } else {
-        cMapPromise = Promise.resolve(undefined);
-      }
-      return cMapPromise.then(() => {
-        return this.extractDataStructures(dict, baseDict, properties);
-      }).then(properties => {
-        this.extractWidths(dict, descriptor, properties);
-        if (type === 'Type3') {
-          properties.isType3Font = true;
-        }
-        return new _fonts.Font(fontName.name, fontFile, properties);
-      });
-    }
-  };
-  return PartialEvaluator;
-}();
-var TranslatedFont = function TranslatedFontClosure() {
-  function TranslatedFont(loadedName, font, dict) {
-    this.loadedName = loadedName;
-    this.font = font;
-    this.dict = dict;
-    this.type3Loaded = null;
-    this.sent = false;
-  }
-  TranslatedFont.prototype = {
-    send(handler) {
-      if (this.sent) {
-        return;
-      }
-      var fontData = this.font.exportData();
-      handler.send('commonobj', [this.loadedName, 'Font', fontData]);
-      this.sent = true;
-    },
-    loadType3Data(evaluator, resources, parentOperatorList, task) {
-      if (!this.font.isType3Font) {
-        throw new Error('Must be a Type3 font.');
-      }
-      if (this.type3Loaded) {
-        return this.type3Loaded;
-      }
-      var type3Options = Object.create(evaluator.options);
-      type3Options.ignoreErrors = false;
-      var type3Evaluator = evaluator.clone(type3Options);
-      var translatedFont = this.font;
-      var loadCharProcsPromise = Promise.resolve();
-      var charProcs = this.dict.get('CharProcs');
-      var fontResources = this.dict.get('Resources') || resources;
-      var charProcKeys = charProcs.getKeys();
-      var charProcOperatorList = Object.create(null);
-      for (var i = 0, n = charProcKeys.length; i < n; ++i) {
-        let key = charProcKeys[i];
-        loadCharProcsPromise = loadCharProcsPromise.then(function () {
-          var glyphStream = charProcs.get(key);
-          var operatorList = new OperatorList();
-          return type3Evaluator.getOperatorList({
-            stream: glyphStream,
-            task,
-            resources: fontResources,
-            operatorList
-          }).then(function () {
-            charProcOperatorList[key] = operatorList.getIR();
-            parentOperatorList.addDependencies(operatorList.dependencies);
-          }).catch(function (reason) {
-            (0, _util.warn)(`Type3 font resource "${key}" is not available.`);
-            var operatorList = new OperatorList();
-            charProcOperatorList[key] = operatorList.getIR();
-          });
-        });
-      }
-      this.type3Loaded = loadCharProcsPromise.then(function () {
-        translatedFont.charProcOperatorList = charProcOperatorList;
-      });
-      return this.type3Loaded;
-    }
-  };
-  return TranslatedFont;
-}();
-var OperatorList = function OperatorListClosure() {
-  var CHUNK_SIZE = 1000;
-  var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
-  function getTransfers(queue) {
-    var transfers = [];
-    var fnArray = queue.fnArray,
-        argsArray = queue.argsArray;
-    for (var i = 0, ii = queue.length; i < ii; i++) {
-      switch (fnArray[i]) {
-        case _util.OPS.paintInlineImageXObject:
-        case _util.OPS.paintInlineImageXObjectGroup:
-        case _util.OPS.paintImageMaskXObject:
-          var arg = argsArray[i][0];
-          if (!arg.cached) {
-            transfers.push(arg.data.buffer);
-          }
-          break;
-      }
-    }
-    return transfers;
-  }
-  function OperatorList(intent, messageHandler, pageIndex) {
-    this.messageHandler = messageHandler;
-    this.fnArray = [];
-    this.argsArray = [];
-    this.dependencies = Object.create(null);
-    this._totalLength = 0;
-    this.pageIndex = pageIndex;
-    this.intent = intent;
-  }
-  OperatorList.prototype = {
-    get length() {
-      return this.argsArray.length;
-    },
-    get totalLength() {
-      return this._totalLength + this.length;
-    },
-    addOp(fn, args) {
-      this.fnArray.push(fn);
-      this.argsArray.push(args);
-      if (this.messageHandler) {
-        if (this.fnArray.length >= CHUNK_SIZE) {
-          this.flush();
-        } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === _util.OPS.restore || fn === _util.OPS.endText)) {
-          this.flush();
-        }
-      }
-    },
-    addDependency(dependency) {
-      if (dependency in this.dependencies) {
-        return;
-      }
-      this.dependencies[dependency] = true;
-      this.addOp(_util.OPS.dependency, [dependency]);
-    },
-    addDependencies(dependencies) {
-      for (var key in dependencies) {
-        this.addDependency(key);
-      }
-    },
-    addOpList(opList) {
-      _util.Util.extendObj(this.dependencies, opList.dependencies);
-      for (var i = 0, ii = opList.length; i < ii; i++) {
-        this.addOp(opList.fnArray[i], opList.argsArray[i]);
-      }
-    },
-    getIR() {
-      return {
-        fnArray: this.fnArray,
-        argsArray: this.argsArray,
-        length: this.length
-      };
-    },
-    flush(lastChunk) {
-      if (this.intent !== 'oplist') {
-        new QueueOptimizer().optimize(this);
-      }
-      var transfers = getTransfers(this);
-      var length = this.length;
-      this._totalLength += length;
-      this.messageHandler.send('RenderPageChunk', {
-        operatorList: {
-          fnArray: this.fnArray,
-          argsArray: this.argsArray,
-          lastChunk,
-          length
-        },
-        pageIndex: this.pageIndex,
-        intent: this.intent
-      }, transfers);
-      this.dependencies = Object.create(null);
-      this.fnArray.length = 0;
-      this.argsArray.length = 0;
-    }
-  };
-  return OperatorList;
-}();
-var StateManager = function StateManagerClosure() {
-  function StateManager(initialState) {
-    this.state = initialState;
-    this.stateStack = [];
-  }
-  StateManager.prototype = {
-    save() {
-      var old = this.state;
-      this.stateStack.push(this.state);
-      this.state = old.clone();
-    },
-    restore() {
-      var prev = this.stateStack.pop();
-      if (prev) {
-        this.state = prev;
-      }
-    },
-    transform(args) {
-      this.state.ctm = _util.Util.transform(this.state.ctm, args);
-    }
-  };
-  return StateManager;
-}();
-var TextState = function TextStateClosure() {
-  function TextState() {
-    this.ctm = new Float32Array(_util.IDENTITY_MATRIX);
-    this.fontName = null;
-    this.fontSize = 0;
-    this.font = null;
-    this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
-    this.textMatrix = _util.IDENTITY_MATRIX.slice();
-    this.textLineMatrix = _util.IDENTITY_MATRIX.slice();
-    this.charSpacing = 0;
-    this.wordSpacing = 0;
-    this.leading = 0;
-    this.textHScale = 1;
-    this.textRise = 0;
-  }
-  TextState.prototype = {
-    setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
-      var m = this.textMatrix;
-      m[0] = a;
-      m[1] = b;
-      m[2] = c;
-      m[3] = d;
-      m[4] = e;
-      m[5] = f;
-    },
-    setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
-      var m = this.textLineMatrix;
-      m[0] = a;
-      m[1] = b;
-      m[2] = c;
-      m[3] = d;
-      m[4] = e;
-      m[5] = f;
-    },
-    translateTextMatrix: function TextState_translateTextMatrix(x, y) {
-      var m = this.textMatrix;
-      m[4] = m[0] * x + m[2] * y + m[4];
-      m[5] = m[1] * x + m[3] * y + m[5];
-    },
-    translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
-      var m = this.textLineMatrix;
-      m[4] = m[0] * x + m[2] * y + m[4];
-      m[5] = m[1] * x + m[3] * y + m[5];
-    },
-    calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
-      var font = this.font;
-      if (!font) {
-        return null;
-      }
-      var m = this.textLineMatrix;
-      if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
-        return null;
-      }
-      var txDiff = e - m[4],
-          tyDiff = f - m[5];
-      if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
-        return null;
-      }
-      var tx,
-          ty,
-          denominator = a * d - b * c;
-      if (font.vertical) {
-        tx = -tyDiff * c / denominator;
-        ty = tyDiff * a / denominator;
-      } else {
-        tx = txDiff * d / denominator;
-        ty = -txDiff * b / denominator;
-      }
-      return {
-        width: tx,
-        height: ty,
-        value: font.vertical ? ty : tx
-      };
-    },
-    calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
-      var tsm = [this.fontSize * this.textHScale, 0, 0, this.fontSize, 0, this.textRise];
-      return _util.Util.transform(ctm, _util.Util.transform(this.textMatrix, tsm));
-    },
-    carriageReturn: function TextState_carriageReturn() {
-      this.translateTextLineMatrix(0, -this.leading);
-      this.textMatrix = this.textLineMatrix.slice();
-    },
-    clone: function TextState_clone() {
-      var clone = Object.create(this);
-      clone.textMatrix = this.textMatrix.slice();
-      clone.textLineMatrix = this.textLineMatrix.slice();
-      clone.fontMatrix = this.fontMatrix.slice();
-      return clone;
-    }
-  };
-  return TextState;
-}();
-var EvalState = function EvalStateClosure() {
-  function EvalState() {
-    this.ctm = new Float32Array(_util.IDENTITY_MATRIX);
-    this.font = null;
-    this.textRenderingMode = _util.TextRenderingMode.FILL;
-    this.fillColorSpace = _colorspace.ColorSpace.singletons.gray;
-    this.strokeColorSpace = _colorspace.ColorSpace.singletons.gray;
-  }
-  EvalState.prototype = {
-    clone: function CanvasExtraState_clone() {
-      return Object.create(this);
-    }
-  };
-  return EvalState;
-}();
-var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
-  var getOPMap = (0, _util.getLookupTableFactory)(function (t) {
-    t['w'] = {
-      id: _util.OPS.setLineWidth,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['J'] = {
-      id: _util.OPS.setLineCap,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['j'] = {
-      id: _util.OPS.setLineJoin,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['M'] = {
-      id: _util.OPS.setMiterLimit,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['d'] = {
-      id: _util.OPS.setDash,
-      numArgs: 2,
-      variableArgs: false
-    };
-    t['ri'] = {
-      id: _util.OPS.setRenderingIntent,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['i'] = {
-      id: _util.OPS.setFlatness,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['gs'] = {
-      id: _util.OPS.setGState,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['q'] = {
-      id: _util.OPS.save,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['Q'] = {
-      id: _util.OPS.restore,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['cm'] = {
-      id: _util.OPS.transform,
-      numArgs: 6,
-      variableArgs: false
-    };
-    t['m'] = {
-      id: _util.OPS.moveTo,
-      numArgs: 2,
-      variableArgs: false
-    };
-    t['l'] = {
-      id: _util.OPS.lineTo,
-      numArgs: 2,
-      variableArgs: false
-    };
-    t['c'] = {
-      id: _util.OPS.curveTo,
-      numArgs: 6,
-      variableArgs: false
-    };
-    t['v'] = {
-      id: _util.OPS.curveTo2,
-      numArgs: 4,
-      variableArgs: false
-    };
-    t['y'] = {
-      id: _util.OPS.curveTo3,
-      numArgs: 4,
-      variableArgs: false
-    };
-    t['h'] = {
-      id: _util.OPS.closePath,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['re'] = {
-      id: _util.OPS.rectangle,
-      numArgs: 4,
-      variableArgs: false
-    };
-    t['S'] = {
-      id: _util.OPS.stroke,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['s'] = {
-      id: _util.OPS.closeStroke,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['f'] = {
-      id: _util.OPS.fill,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['F'] = {
-      id: _util.OPS.fill,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['f*'] = {
-      id: _util.OPS.eoFill,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['B'] = {
-      id: _util.OPS.fillStroke,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['B*'] = {
-      id: _util.OPS.eoFillStroke,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['b'] = {
-      id: _util.OPS.closeFillStroke,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['b*'] = {
-      id: _util.OPS.closeEOFillStroke,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['n'] = {
-      id: _util.OPS.endPath,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['W'] = {
-      id: _util.OPS.clip,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['W*'] = {
-      id: _util.OPS.eoClip,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['BT'] = {
-      id: _util.OPS.beginText,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['ET'] = {
-      id: _util.OPS.endText,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['Tc'] = {
-      id: _util.OPS.setCharSpacing,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['Tw'] = {
-      id: _util.OPS.setWordSpacing,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['Tz'] = {
-      id: _util.OPS.setHScale,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['TL'] = {
-      id: _util.OPS.setLeading,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['Tf'] = {
-      id: _util.OPS.setFont,
-      numArgs: 2,
-      variableArgs: false
-    };
-    t['Tr'] = {
-      id: _util.OPS.setTextRenderingMode,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['Ts'] = {
-      id: _util.OPS.setTextRise,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['Td'] = {
-      id: _util.OPS.moveText,
-      numArgs: 2,
-      variableArgs: false
-    };
-    t['TD'] = {
-      id: _util.OPS.setLeadingMoveText,
-      numArgs: 2,
-      variableArgs: false
-    };
-    t['Tm'] = {
-      id: _util.OPS.setTextMatrix,
-      numArgs: 6,
-      variableArgs: false
-    };
-    t['T*'] = {
-      id: _util.OPS.nextLine,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['Tj'] = {
-      id: _util.OPS.showText,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['TJ'] = {
-      id: _util.OPS.showSpacedText,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['\''] = {
-      id: _util.OPS.nextLineShowText,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['"'] = {
-      id: _util.OPS.nextLineSetSpacingShowText,
-      numArgs: 3,
-      variableArgs: false
-    };
-    t['d0'] = {
-      id: _util.OPS.setCharWidth,
-      numArgs: 2,
-      variableArgs: false
-    };
-    t['d1'] = {
-      id: _util.OPS.setCharWidthAndBounds,
-      numArgs: 6,
-      variableArgs: false
-    };
-    t['CS'] = {
-      id: _util.OPS.setStrokeColorSpace,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['cs'] = {
-      id: _util.OPS.setFillColorSpace,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['SC'] = {
-      id: _util.OPS.setStrokeColor,
-      numArgs: 4,
-      variableArgs: true
-    };
-    t['SCN'] = {
-      id: _util.OPS.setStrokeColorN,
-      numArgs: 33,
-      variableArgs: true
-    };
-    t['sc'] = {
-      id: _util.OPS.setFillColor,
-      numArgs: 4,
-      variableArgs: true
-    };
-    t['scn'] = {
-      id: _util.OPS.setFillColorN,
-      numArgs: 33,
-      variableArgs: true
-    };
-    t['G'] = {
-      id: _util.OPS.setStrokeGray,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['g'] = {
-      id: _util.OPS.setFillGray,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['RG'] = {
-      id: _util.OPS.setStrokeRGBColor,
-      numArgs: 3,
-      variableArgs: false
-    };
-    t['rg'] = {
-      id: _util.OPS.setFillRGBColor,
-      numArgs: 3,
-      variableArgs: false
-    };
-    t['K'] = {
-      id: _util.OPS.setStrokeCMYKColor,
-      numArgs: 4,
-      variableArgs: false
-    };
-    t['k'] = {
-      id: _util.OPS.setFillCMYKColor,
-      numArgs: 4,
-      variableArgs: false
-    };
-    t['sh'] = {
-      id: _util.OPS.shadingFill,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['BI'] = {
-      id: _util.OPS.beginInlineImage,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['ID'] = {
-      id: _util.OPS.beginImageData,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['EI'] = {
-      id: _util.OPS.endInlineImage,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['Do'] = {
-      id: _util.OPS.paintXObject,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['MP'] = {
-      id: _util.OPS.markPoint,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['DP'] = {
-      id: _util.OPS.markPointProps,
-      numArgs: 2,
-      variableArgs: false
-    };
-    t['BMC'] = {
-      id: _util.OPS.beginMarkedContent,
-      numArgs: 1,
-      variableArgs: false
-    };
-    t['BDC'] = {
-      id: _util.OPS.beginMarkedContentProps,
-      numArgs: 2,
-      variableArgs: false
-    };
-    t['EMC'] = {
-      id: _util.OPS.endMarkedContent,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['BX'] = {
-      id: _util.OPS.beginCompat,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['EX'] = {
-      id: _util.OPS.endCompat,
-      numArgs: 0,
-      variableArgs: false
-    };
-    t['BM'] = null;
-    t['BD'] = null;
-    t['true'] = null;
-    t['fa'] = null;
-    t['fal'] = null;
-    t['fals'] = null;
-    t['false'] = null;
-    t['nu'] = null;
-    t['nul'] = null;
-    t['null'] = null;
-  });
-  function EvaluatorPreprocessor(stream, xref, stateManager) {
-    this.opMap = getOPMap();
-    this.parser = new _parser.Parser(new _parser.Lexer(stream, this.opMap), false, xref);
-    this.stateManager = stateManager;
-    this.nonProcessedArgs = [];
-  }
-  EvaluatorPreprocessor.prototype = {
-    get savedStatesDepth() {
-      return this.stateManager.stateStack.length;
-    },
-    read: function EvaluatorPreprocessor_read(operation) {
-      var args = operation.args;
-      while (true) {
-        var obj = this.parser.getObj();
-        if ((0, _primitives.isCmd)(obj)) {
-          var cmd = obj.cmd;
-          var opSpec = this.opMap[cmd];
-          if (!opSpec) {
-            (0, _util.warn)('Unknown command "' + cmd + '"');
-            continue;
-          }
-          var fn = opSpec.id;
-          var numArgs = opSpec.numArgs;
-          var argsLength = args !== null ? args.length : 0;
-          if (!opSpec.variableArgs) {
-            if (argsLength !== numArgs) {
-              var nonProcessedArgs = this.nonProcessedArgs;
-              while (argsLength > numArgs) {
-                nonProcessedArgs.push(args.shift());
-                argsLength--;
-              }
-              while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
-                if (args === null) {
-                  args = [];
-                }
-                args.unshift(nonProcessedArgs.pop());
-                argsLength++;
-              }
-            }
-            if (argsLength < numArgs) {
-              (0, _util.warn)('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
-              if (args !== null) {
-                args.length = 0;
-              }
-              continue;
-            }
-          } else if (argsLength > numArgs) {
-            (0, _util.info)('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
-          }
-          this.preprocessCommand(fn, args);
-          operation.fn = fn;
-          operation.args = args;
-          return true;
-        }
-        if ((0, _primitives.isEOF)(obj)) {
-          return false;
-        }
-        if (obj !== null) {
-          if (args === null) {
-            args = [];
-          }
-          args.push(obj);
-          if (args.length > 33) {
-            throw new _util.FormatError('Too many arguments');
-          }
-        }
-      }
-    },
-    preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
-      switch (fn | 0) {
-        case _util.OPS.save:
-          this.stateManager.save();
-          break;
-        case _util.OPS.restore:
-          this.stateManager.restore();
-          break;
-        case _util.OPS.transform:
-          this.stateManager.transform(args);
-          break;
-      }
-    }
-  };
-  return EvaluatorPreprocessor;
-}();
-var QueueOptimizer = function QueueOptimizerClosure() {
-  function addState(parentState, pattern, fn) {
-    var state = parentState;
-    for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
-      var item = pattern[i];
-      state = state[item] || (state[item] = []);
-    }
-    state[pattern[pattern.length - 1]] = fn;
-  }
-  function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
-    var iFirstPIMXO = iFirstSave + 2;
-    for (var i = 0; i < count; i++) {
-      var arg = argsArray[iFirstPIMXO + 4 * i];
-      var imageMask = arg.length === 1 && arg[0];
-      if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
-        fnArray[iFirstPIMXO + 4 * i] = _util.OPS.paintSolidColorImageMask;
-        continue;
-      }
-      break;
-    }
-    return count - i;
-  }
-  var InitialState = [];
-  addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintInlineImageXObject, _util.OPS.restore], function foundInlineImageGroup(context) {
-    var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
-    var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
-    var MAX_WIDTH = 1000;
-    var IMAGE_PADDING = 1;
-    var fnArray = context.fnArray,
-        argsArray = context.argsArray;
-    var curr = context.iCurr;
-    var iFirstSave = curr - 3;
-    var iFirstTransform = curr - 2;
-    var iFirstPIIXO = curr - 1;
-    var i = iFirstSave + 4;
-    var ii = fnArray.length;
-    while (i + 3 < ii) {
-      if (fnArray[i] !== _util.OPS.save || fnArray[i + 1] !== _util.OPS.transform || fnArray[i + 2] !== _util.OPS.paintInlineImageXObject || fnArray[i + 3] !== _util.OPS.restore) {
-        break;
-      }
-      i += 4;
-    }
-    var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
-    if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
-      return i;
-    }
-    var maxX = 0;
-    var map = [],
-        maxLineHeight = 0;
-    var currentX = IMAGE_PADDING,
-        currentY = IMAGE_PADDING;
-    var q;
-    for (q = 0; q < count; q++) {
-      var transform = argsArray[iFirstTransform + (q << 2)];
-      var img = argsArray[iFirstPIIXO + (q << 2)][0];
-      if (currentX + img.width > MAX_WIDTH) {
-        maxX = Math.max(maxX, currentX);
-        currentY += maxLineHeight + 2 * IMAGE_PADDING;
-        currentX = 0;
-        maxLineHeight = 0;
-      }
-      map.push({
-        transform,
-        x: currentX,
-        y: currentY,
-        w: img.width,
-        h: img.height
-      });
-      currentX += img.width + 2 * IMAGE_PADDING;
-      maxLineHeight = Math.max(maxLineHeight, img.height);
-    }
-    var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
-    var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
-    var imgData = new Uint8Array(imgWidth * imgHeight * 4);
-    var imgRowSize = imgWidth << 2;
-    for (q = 0; q < count; q++) {
-      var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
-      var rowSize = map[q].w << 2;
-      var dataOffset = 0;
-      var offset = map[q].x + map[q].y * imgWidth << 2;
-      imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
-      for (var k = 0, kk = map[q].h; k < kk; k++) {
-        imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
-        dataOffset += rowSize;
-        offset += imgRowSize;
-      }
-      imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
-      while (offset >= 0) {
-        data[offset - 4] = data[offset];
-        data[offset - 3] = data[offset + 1];
-        data[offset - 2] = data[offset + 2];
-        data[offset - 1] = data[offset + 3];
-        data[offset + rowSize] = data[offset + rowSize - 4];
-        data[offset + rowSize + 1] = data[offset + rowSize - 3];
-        data[offset + rowSize + 2] = data[offset + rowSize - 2];
-        data[offset + rowSize + 3] = data[offset + rowSize - 1];
-        offset -= imgRowSize;
-      }
-    }
-    fnArray.splice(iFirstSave, count * 4, _util.OPS.paintInlineImageXObjectGroup);
-    argsArray.splice(iFirstSave, count * 4, [{
-      width: imgWidth,
-      height: imgHeight,
-      kind: _util.ImageKind.RGBA_32BPP,
-      data: imgData
-    }, map]);
-    return iFirstSave + 1;
-  });
-  addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintImageMaskXObject, _util.OPS.restore], function foundImageMaskGroup(context) {
-    var MIN_IMAGES_IN_MASKS_BLOCK = 10;
-    var MAX_IMAGES_IN_MASKS_BLOCK = 100;
-    var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
-    var fnArray = context.fnArray,
-        argsArray = context.argsArray;
-    var curr = context.iCurr;
-    var iFirstSave = curr - 3;
-    var iFirstTransform = curr - 2;
-    var iFirstPIMXO = curr - 1;
-    var i = iFirstSave + 4;
-    var ii = fnArray.length;
-    while (i + 3 < ii) {
-      if (fnArray[i] !== _util.OPS.save || fnArray[i + 1] !== _util.OPS.transform || fnArray[i + 2] !== _util.OPS.paintImageMaskXObject || fnArray[i + 3] !== _util.OPS.restore) {
-        break;
-      }
-      i += 4;
-    }
-    var count = (i - iFirstSave) / 4;
-    count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
-    if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
-      return i;
-    }
-    var q;
-    var isSameImage = false;
-    var iTransform, transformArgs;
-    var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
-    if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
-      isSameImage = true;
-      var firstTransformArg0 = argsArray[iFirstTransform][0];
-      var firstTransformArg3 = argsArray[iFirstTransform][3];
-      iTransform = iFirstTransform + 4;
-      var iPIMXO = iFirstPIMXO + 4;
-      for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
-        transformArgs = argsArray[iTransform];
-        if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
-          if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
-            isSameImage = false;
-          } else {
-            count = q;
-          }
-          break;
-        }
-      }
-    }
-    if (isSameImage) {
-      count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
-      var positions = new Float32Array(count * 2);
-      iTransform = iFirstTransform;
-      for (q = 0; q < count; q++, iTransform += 4) {
-        transformArgs = argsArray[iTransform];
-        positions[q << 1] = transformArgs[4];
-        positions[(q << 1) + 1] = transformArgs[5];
-      }
-      fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageMaskXObjectRepeat);
-      argsArray.splice(iFirstSave, count * 4, [firstPIMXOArg0, firstTransformArg0, firstTransformArg3, positions]);
-    } else {
-      count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
-      var images = [];
-      for (q = 0; q < count; q++) {
-        transformArgs = argsArray[iFirstTransform + (q << 2)];
-        var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
-        images.push({
-          data: maskParams.data,
-          width: maskParams.width,
-          height: maskParams.height,
-          transform: transformArgs
-        });
-      }
-      fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageMaskXObjectGroup);
-      argsArray.splice(iFirstSave, count * 4, [images]);
-    }
-    return iFirstSave + 1;
-  });
-  addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintImageXObject, _util.OPS.restore], function (context) {
-    var MIN_IMAGES_IN_BLOCK = 3;
-    var MAX_IMAGES_IN_BLOCK = 1000;
-    var fnArray = context.fnArray,
-        argsArray = context.argsArray;
-    var curr = context.iCurr;
-    var iFirstSave = curr - 3;
-    var iFirstTransform = curr - 2;
-    var iFirstPIXO = curr - 1;
-    var iFirstRestore = curr;
-    if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
-      return iFirstRestore + 1;
-    }
-    var firstPIXOArg0 = argsArray[iFirstPIXO][0];
-    var firstTransformArg0 = argsArray[iFirstTransform][0];
-    var firstTransformArg3 = argsArray[iFirstTransform][3];
-    var i = iFirstSave + 4;
-    var ii = fnArray.length;
-    while (i + 3 < ii) {
-      if (fnArray[i] !== _util.OPS.save || fnArray[i + 1] !== _util.OPS.transform || fnArray[i + 2] !== _util.OPS.paintImageXObject || fnArray[i + 3] !== _util.OPS.restore) {
-        break;
-      }
-      if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
-        break;
-      }
-      if (argsArray[i + 2][0] !== firstPIXOArg0) {
-        break;
-      }
-      i += 4;
-    }
-    var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
-    if (count < MIN_IMAGES_IN_BLOCK) {
-      return i;
-    }
-    var positions = new Float32Array(count * 2);
-    var iTransform = iFirstTransform;
-    for (var q = 0; q < count; q++, iTransform += 4) {
-      var transformArgs = argsArray[iTransform];
-      positions[q << 1] = transformArgs[4];
-      positions[(q << 1) + 1] = transformArgs[5];
-    }
-    var args = [firstPIXOArg0, firstTransformArg0, firstTransformArg3, positions];
-    fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageXObjectRepeat);
-    argsArray.splice(iFirstSave, count * 4, args);
-    return iFirstSave + 1;
-  });
-  addState(InitialState, [_util.OPS.beginText, _util.OPS.setFont, _util.OPS.setTextMatrix, _util.OPS.showText, _util.OPS.endText], function (context) {
-    var MIN_CHARS_IN_BLOCK = 3;
-    var MAX_CHARS_IN_BLOCK = 1000;
-    var fnArray = context.fnArray,
-        argsArray = context.argsArray;
-    var curr = context.iCurr;
-    var iFirstBeginText = curr - 4;
-    var iFirstSetFont = curr - 3;
-    var iFirstSetTextMatrix = curr - 2;
-    var iFirstShowText = curr - 1;
-    var iFirstEndText = curr;
-    var firstSetFontArg0 = argsArray[iFirstSetFont][0];
-    var firstSetFontArg1 = argsArray[iFirstSetFont][1];
-    var i = iFirstBeginText + 5;
-    var ii = fnArray.length;
-    while (i + 4 < ii) {
-      if (fnArray[i] !== _util.OPS.beginText || fnArray[i + 1] !== _util.OPS.setFont || fnArray[i + 2] !== _util.OPS.setTextMatrix || fnArray[i + 3] !== _util.OPS.showText || fnArray[i + 4] !== _util.OPS.endText) {
-        break;
-      }
-      if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
-        break;
-      }
-      i += 5;
-    }
-    var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
-    if (count < MIN_CHARS_IN_BLOCK) {
-      return i;
-    }
-    var iFirst = iFirstBeginText;
-    if (iFirstBeginText >= 4 && fnArray[iFirstBeginText - 4] === fnArray[iFirstSetFont] && fnArray[iFirstBeginText - 3] === fnArray[iFirstSetTextMatrix] && fnArray[iFirstBeginText - 2] === fnArray[iFirstShowText] && fnArray[iFirstBeginText - 1] === fnArray[iFirstEndText] && argsArray[iFirstBeginText - 4][0] === firstSetFontArg0 && argsArray[iFirstBeginText - 4][1] === firstSetFontArg1) {
-      count++;
-      iFirst -= 5;
-    }
-    var iEndText = iFirst + 4;
-    for (var q = 1; q < count; q++) {
-      fnArray.splice(iEndText, 3);
-      argsArray.splice(iEndText, 3);
-      iEndText += 2;
-    }
-    return iEndText + 1;
-  });
-  function QueueOptimizer() {}
-  QueueOptimizer.prototype = {
-    optimize: function QueueOptimizer_optimize(queue) {
-      var fnArray = queue.fnArray,
-          argsArray = queue.argsArray;
-      var context = {
-        iCurr: 0,
-        fnArray,
-        argsArray
-      };
-      var state;
-      var i = 0,
-          ii = fnArray.length;
-      while (i < ii) {
-        state = (state || InitialState)[fnArray[i]];
-        if (typeof state === 'function') {
-          context.iCurr = i;
-          i = state(context);
-          state = undefined;
-          ii = context.fnArray.length;
-        } else {
-          i++;
-        }
-      }
-    }
-  };
-  return QueueOptimizer;
-}();
-exports.OperatorList = OperatorList;
-exports.PartialEvaluator = PartialEvaluator;
-
-/***/ }),
 /* 13 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.CFFCompiler = exports.CFFPrivateDict = exports.CFFTopDict = exports.CFFCharset = exports.CFFIndex = exports.CFFStrings = exports.CFFHeader = exports.CFF = exports.CFFParser = exports.CFFStandardStrings = undefined;
 
 var _util = __w_pdfjs_require__(0);
 
-var _charsets = __w_pdfjs_require__(31);
+var _charsets = __w_pdfjs_require__(33);
 
 var _encodings = __w_pdfjs_require__(4);
 
 var MAX_SUBR_NESTING = 10;
 var CFFStandardStrings = ['.notdef', 'space', 'exclam', 'quotedbl', 'numbersign', 'dollar', 'percent', 'ampersand', 'quoteright', 'parenleft', 'parenright', 'asterisk', 'plus', 'comma', 'hyphen', 'period', 'slash', 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon', 'less', 'equal', 'greater', 'question', 'at', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'bracketleft', 'backslash', 'bracketright', 'asciicircum', 'underscore', 'quoteleft', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'braceleft', 'bar', 'braceright', 'asciitilde', 'exclamdown', 'cent', 'sterling', 'fraction', 'yen', 'florin', 'section', 'currency', 'quotesingle', 'quotedblleft', 'guillemotleft', 'guilsinglleft', 'guilsinglright', 'fi', 'fl', 'endash', 'dagger', 'daggerdbl', 'periodcentered', 'paragraph', 'bullet', 'quotesinglbase', 'quotedblbase', 'quotedblright', 'guillemotright', 'ellipsis', 'perthousand', 'questiondown', 'grave', 'acute', 'circumflex', 'tilde', 'macron', 'breve', 'dotaccent', 'dieresis', 'ring', 'cedilla', 'hungarumlaut', 'ogonek', 'caron', 'emdash', 'AE', 'ordfeminine', 'Lslash', 'Oslash', 'OE', 'ordmasculine', 'ae', 'dotlessi', 'lslash', 'oslash', 'oe', 'germandbls', 'onesuperior', 'logicalnot', 'mu', 'trademark', 'Eth', 'onehalf', 'plusminus', 'Thorn', 'onequarter', 'divide', 'brokenbar', 'degree', 'thorn', 'threequarters', 'twosuperior', 'registered', 'minus', 'eth', 'multiply', 'threesuperior', 'copyright', 'Aacute', 'Acircumflex', 'Adieresis', 'Agrave', 'Aring', 'Atilde', 'Ccedilla', 'Eacute', 'Ecircumflex', 'Edieresis', 'Egrave', 'Iacute', 'Icircumflex', 'Idieresis', 'Igrave', 'Ntilde', 'Oacute', 'Ocircumflex', 'Odieresis', 'Ograve', 'Otilde', 'Scaron', 'Uacute', 'Ucircumflex', 'Udieresis', 'Ugrave', 'Yacute', 'Ydieresis', 'Zcaron', 'aacute', 'acircumflex', 'adieresis', 'agrave', 'aring', 'atilde', 'ccedilla', 'eacute', 'ecircumflex', 'edieresis', 'egrave', 'iacute', 'icircumflex', 'idieresis', 'igrave', 'ntilde', 'oacute', 'ocircumflex', 'odieresis', 'ograve', 'otilde', 'scaron', 'uacute', 'ucircumflex', 'udieresis', 'ugrave', 'yacute', 'ydieresis', 'zcaron', 'exclamsmall', 'Hungarumlautsmall', 'dollaroldstyle', 'dollarsuperior', 'ampersandsmall', 'Acutesmall', 'parenleftsuperior', 'parenrightsuperior', 'twodotenleader', 'onedotenleader', 'zerooldstyle', 'oneoldstyle', 'twooldstyle', 'threeoldstyle', 'fouroldstyle', 'fiveoldstyle', 'sixoldstyle', 'sevenoldstyle', 'eightoldstyle', 'nineoldstyle', 'commasuperior', 'threequartersemdash', 'periodsuperior', 'questionsmall', 'asuperior', 'bsuperior', 'centsuperior', 'dsuperior', 'esuperior', 'isuperior', 'lsuperior', 'msuperior', 'nsuperior', 'osuperior', 'rsuperior', 'ssuperior', 'tsuperior', 'ff', 'ffi', 'ffl', 'parenleftinferior', 'parenrightinferior', 'Circumflexsmall', 'hyphensuperior', 'Gravesmall', 'Asmall', 'Bsmall', 'Csmall', 'Dsmall', 'Esmall', 'Fsmall', 'Gsmall', 'Hsmall', 'Ismall', 'Jsmall', 'Ksmall', 'Lsmall', 'Msmall', 'Nsmall', 'Osmall', 'Psmall', 'Qsmall', 'Rsmall', 'Ssmall', 'Tsmall', 'Usmall', 'Vsmall', 'Wsmall', 'Xsmall', 'Ysmall', 'Zsmall', 'colonmonetary', 'onefitted', 'rupiah', 'Tildesmall', 'exclamdownsmall', 'centoldstyle', 'Lslashsmall', 'Scaronsmall', 'Zcaronsmall', 'Dieresissmall', 'Brevesmall', 'Caronsmall', 'Dotaccentsmall', 'Macronsmall', 'figuredash', 'hypheninferior', 'Ogoneksmall', 'Ringsmall', 'Cedillasmall', 'questiondownsmall', 'oneeighth', 'threeeighths', 'fiveeighths', 'seveneighths', 'onethird', 'twothirds', 'zerosuperior', 'foursuperior', 'fivesuperior', 'sixsuperior', 'sevensuperior', 'eightsuperior', 'ninesuperior', 'zeroinferior', 'oneinferior', 'twoinferior', 'threeinferior', 'fourinferior', 'fiveinferior', 'sixinferior', 'seveninferior', 'eightinferior', 'nineinferior', 'centinferior', 'dollarinferior', 'periodinferior', 'commainferior', 'Agravesmall', 'Aacutesmall', 'Acircumflexsmall', 'Atildesmall', 'Adieresissmall', 'Aringsmall', 'AEsmall', 'Ccedillasmall', 'Egravesmall', 'Eacutesmall', 'Ecircumflexsmall', 'Edieresissmall', 'Igravesmall', 'Iacutesmall', 'Icircumflexsmall', 'Idieresissmall', 'Ethsmall', 'Ntildesmall', 'Ogravesmall', 'Oacutesmall', 'Ocircumflexsmall', 'Otildesmall', 'Odieresissmall', 'OEsmall', 'Oslashsmall', 'Ugravesmall', 'Uacutesmall', 'Ucircumflexsmall', 'Udieresissmall', 'Yacutesmall', 'Thornsmall', 'Ydieresissmall', '001.000', '001.001', '001.002', '001.003', 'Black', 'Bold', 'Book', 'Light', 'Medium', 'Regular', 'Roman', 'Semibold'];
 var CFFParser = function CFFParserClosure() {
   var CharstringValidationData = [null, {
     id: 'hstem',
@@ -22232,17 +19709,17 @@ Object.defineProperty(exports, "__esModu
   value: true
 });
 exports.PostScriptCompiler = exports.PostScriptEvaluator = exports.PDFFunctionFactory = exports.isPDFFunction = undefined;
 
 var _util = __w_pdfjs_require__(0);
 
 var _primitives = __w_pdfjs_require__(1);
 
-var _ps_parser = __w_pdfjs_require__(37);
+var _ps_parser = __w_pdfjs_require__(39);
 
 let IsEvalSupportedCached = {
   get value() {
     return (0, _util.shadow)(this, 'value', (0, _util.isEvalSupported)());
   }
 };
 class PDFFunctionFactory {
   constructor({ xref, isEvalSupported = true }) {
@@ -23279,18 +20756,18 @@ exports.PostScriptCompiler = PostScriptC
 
 /***/ }),
 /* 17 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-var pdfjsVersion = '2.0.106';
-var pdfjsBuild = '0052dc2b';
+var pdfjsVersion = '2.0.120';
+var pdfjsBuild = 'e162df59';
 var pdfjsCoreWorker = __w_pdfjs_require__(18);
 exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
 
 /***/ }),
 /* 18 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
@@ -23475,17 +20952,17 @@ var WorkerMessageHandler = {
     });
   },
   createDocumentHandler(docParams, port) {
     var pdfManager;
     var terminated = false;
     var cancelXHRs = null;
     var WorkerTasks = [];
     let apiVersion = docParams.apiVersion;
-    let workerVersion = '2.0.106';
+    let workerVersion = '2.0.120';
     if (apiVersion !== null && 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 _util.MessageHandler(workerHandlerName, docId, port);
     handler.postMessageTransfers = docParams.postMessageTransfers;
@@ -26926,17 +24403,17 @@ if (isReadableStreamSupported) {
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.NetworkPdfManager = exports.LocalPdfManager = undefined;
 
 var _util = __w_pdfjs_require__(0);
 
-var _chunked_stream = __w_pdfjs_require__(7);
+var _chunked_stream = __w_pdfjs_require__(8);
 
 var _document = __w_pdfjs_require__(23);
 
 var _stream = __w_pdfjs_require__(2);
 
 var BasePdfManager = function BasePdfManagerClosure() {
   function BasePdfManager() {
     throw new Error('Cannot initialize BaseManagerManager');
@@ -27108,32 +24585,34 @@ exports.NetworkPdfManager = NetworkPdfMa
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.PDFDocument = exports.Page = undefined;
 
-var _obj = __w_pdfjs_require__(8);
+var _obj = __w_pdfjs_require__(9);
 
 var _primitives = __w_pdfjs_require__(1);
 
 var _util = __w_pdfjs_require__(0);
 
 var _stream = __w_pdfjs_require__(2);
 
-var _evaluator = __w_pdfjs_require__(12);
-
-var _annotation = __w_pdfjs_require__(40);
-
-var _crypto = __w_pdfjs_require__(11);
+var _annotation = __w_pdfjs_require__(29);
+
+var _crypto = __w_pdfjs_require__(12);
 
 var _parser = __w_pdfjs_require__(5);
 
+var _operator_list = __w_pdfjs_require__(6);
+
+var _evaluator = __w_pdfjs_require__(30);
+
 var _function = __w_pdfjs_require__(16);
 
 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;
   }
@@ -27274,17 +24753,17 @@ var Page = function PageClosure() {
         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 _evaluator.OperatorList(intent, handler, this.pageIndex);
+        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,
@@ -29209,17 +26688,17 @@ exports.Jbig2Stream = Jbig2Stream;
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.Jbig2Image = undefined;
 
 var _util = __w_pdfjs_require__(0);
 
-var _arithmetic_decoder = __w_pdfjs_require__(10);
+var _arithmetic_decoder = __w_pdfjs_require__(11);
 
 let Jbig2Error = function Jbig2ErrorClosure() {
   function Jbig2Error(msg) {
     this.message = 'JBIG2 error: ' + msg;
   }
   Jbig2Error.prototype = new Error();
   Jbig2Error.prototype.name = 'Jbig2Error';
   Jbig2Error.constructor = Jbig2Error;
@@ -30446,16 +27925,3323 @@ exports.Jbig2Image = Jbig2Image;
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
+exports.AnnotationFactory = exports.AnnotationBorderStyle = exports.Annotation = undefined;
+
+var _util = __w_pdfjs_require__(0);
+
+var _obj = __w_pdfjs_require__(9);
+
+var _primitives = __w_pdfjs_require__(1);
+
+var _colorspace = __w_pdfjs_require__(3);
+
+var _operator_list = __w_pdfjs_require__(6);
+
+var _stream = __w_pdfjs_require__(2);
+
+class AnnotationFactory {
+  static create(xref, ref, pdfManager, idFactory) {
+    let dict = xref.fetchIfRef(ref);
+    if (!(0, _primitives.isDict)(dict)) {
+      return;
+    }
+    let id = (0, _primitives.isRef)(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
+    let subtype = dict.get('Subtype');
+    subtype = (0, _primitives.isName)(subtype) ? subtype.name : null;
+    let parameters = {
+      xref,
+      dict,
+      ref: (0, _primitives.isRef)(ref) ? ref : null,
+      subtype,
+      id,
+      pdfManager
+    };
+    switch (subtype) {
+      case 'Link':
+        return new LinkAnnotation(parameters);
+      case 'Text':
+        return new TextAnnotation(parameters);
+      case 'Widget':
+        let fieldType = _util.Util.getInheritableProperty(dict, 'FT');
+        fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null;
+        switch (fieldType) {
+          case 'Tx':
+            return new TextWidgetAnnotation(parameters);
+          case 'Btn':
+            return new ButtonWidgetAnnotation(parameters);
+          case 'Ch':
+            return new ChoiceWidgetAnnotation(parameters);
+        }
+        (0, _util.warn)('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
+        return new WidgetAnnotation(parameters);
+      case 'Popup':
+        return new PopupAnnotation(parameters);
+      case 'Line':
+        return new LineAnnotation(parameters);
+      case 'Square':
+        return new SquareAnnotation(parameters);
+      case 'Circle':
+        return new CircleAnnotation(parameters);
+      case 'PolyLine':
+        return new PolylineAnnotation(parameters);
+      case 'Polygon':
+        return new PolygonAnnotation(parameters);
+      case 'Highlight':
+        return new HighlightAnnotation(parameters);
+      case 'Underline':
+        return new UnderlineAnnotation(parameters);
+      case 'Squiggly':
+        return new SquigglyAnnotation(parameters);
+      case 'StrikeOut':
+        return new StrikeOutAnnotation(parameters);
+      case 'Stamp':
+        return new StampAnnotation(parameters);
+      case 'FileAttachment':
+        return new FileAttachmentAnnotation(parameters);
+      default:
+        if (!subtype) {
+          (0, _util.warn)('Annotation is missing the required /Subtype.');
+        } else {
+          (0, _util.warn)('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
+        }
+        return new Annotation(parameters);
+    }
+  }
+}
+function getTransformMatrix(rect, bbox, matrix) {
+  let bounds = _util.Util.getAxialAlignedBoundingBox(bbox, matrix);
+  let minX = bounds[0];
+  let minY = bounds[1];
+  let maxX = bounds[2];
+  let maxY = bounds[3];
+  if (minX === maxX || minY === maxY) {
+    return [1, 0, 0, 1, rect[0], rect[1]];
+  }
+  let xRatio = (rect[2] - rect[0]) / (maxX - minX);
+  let yRatio = (rect[3] - rect[1]) / (maxY - minY);
+  return [xRatio, 0, 0, yRatio, rect[0] - minX * xRatio, rect[1] - minY * yRatio];
+}
+class Annotation {
+  constructor(params) {
+    let dict = params.dict;
+    this.setFlags(dict.get('F'));
+    this.setRectangle(dict.getArray('Rect'));
+    this.setColor(dict.getArray('C'));
+    this.setBorderStyle(dict);
+    this.setAppearance(dict);
+    this.data = {
+      annotationFlags: this.flags,
+      borderStyle: this.borderStyle,
+      color: this.color,
+      hasAppearance: !!this.appearance,
+      id: params.id,
+      rect: this.rectangle,
+      subtype: params.subtype
+    };
+  }
+  _hasFlag(flags, flag) {
+    return !!(flags & flag);
+  }
+  _isViewable(flags) {
+    return !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, _util.AnnotationFlag.HIDDEN) && !this._hasFlag(flags, _util.AnnotationFlag.NOVIEW);
+  }
+  _isPrintable(flags) {
+    return this._hasFlag(flags, _util.AnnotationFlag.PRINT) && !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, _util.AnnotationFlag.HIDDEN);
+  }
+  get viewable() {
+    if (this.flags === 0) {
+      return true;
+    }
+    return this._isViewable(this.flags);
+  }
+  get printable() {
+    if (this.flags === 0) {
+      return false;
+    }
+    return this._isPrintable(this.flags);
+  }
+  setFlags(flags) {
+    this.flags = Number.isInteger(flags) && flags > 0 ? flags : 0;
+  }
+  hasFlag(flag) {
+    return this._hasFlag(this.flags, flag);
+  }
+  setRectangle(rectangle) {
+    if (Array.isArray(rectangle) && rectangle.length === 4) {
+      this.rectangle = _util.Util.normalizeRect(rectangle);
+    } else {
+      this.rectangle = [0, 0, 0, 0];
+    }
+  }
+  setColor(color) {
+    let rgbColor = new Uint8Array(3);
+    if (!Array.isArray(color)) {
+      this.color = rgbColor;
+      return;
+    }
+    switch (color.length) {
+      case 0:
+        this.color = null;
+        break;
+      case 1:
+        _colorspace.ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
+        this.color = rgbColor;
+        break;
+      case 3:
+        _colorspace.ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
+        this.color = rgbColor;
+        break;
+      case 4:
+        _colorspace.ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
+        this.color = rgbColor;
+        break;
+      default:
+        this.color = rgbColor;
+        break;
+    }
+  }
+  setBorderStyle(borderStyle) {
+    this.borderStyle = new AnnotationBorderStyle();
+    if (!(0, _primitives.isDict)(borderStyle)) {
+      return;
+    }
+    if (borderStyle.has('BS')) {
+      let dict = borderStyle.get('BS');
+      let dictType = dict.get('Type');
+      if (!dictType || (0, _primitives.isName)(dictType, 'Border')) {
+        this.borderStyle.setWidth(dict.get('W'));
+        this.borderStyle.setStyle(dict.get('S'));
+        this.borderStyle.setDashArray(dict.getArray('D'));
+      }
+    } else if (borderStyle.has('Border')) {
+      let array = borderStyle.getArray('Border');
+      if (Array.isArray(array) && array.length >= 3) {
+        this.borderStyle.setHorizontalCornerRadius(array[0]);
+        this.borderStyle.setVerticalCornerRadius(array[1]);
+        this.borderStyle.setWidth(array[2]);
+        if (array.length === 4) {
+          this.borderStyle.setDashArray(array[3]);
+        }
+      }
+    } else {
+      this.borderStyle.setWidth(0);
+    }
+  }
+  setAppearance(dict) {
+    this.appearance = null;
+    let appearanceStates = dict.get('AP');
+    if (!(0, _primitives.isDict)(appearanceStates)) {
+      return;
+    }
+    let normalAppearanceState = appearanceStates.get('N');
+    if ((0, _primitives.isStream)(normalAppearanceState)) {
+      this.appearance = normalAppearanceState;
+      return;
+    }
+    if (!(0, _primitives.isDict)(normalAppearanceState)) {
+      return;
+    }
+    let as = dict.get('AS');
+    if (!(0, _primitives.isName)(as) || !normalAppearanceState.has(as.name)) {
+      return;
+    }
+    this.appearance = normalAppearanceState.get(as.name);
+  }
+  _preparePopup(dict) {
+    if (!dict.has('C')) {
+      this.data.color = null;
+    }
+    this.data.hasPopup = dict.has('Popup');
+    this.data.title = (0, _util.stringToPDFString)(dict.get('T') || '');
+    this.data.contents = (0, _util.stringToPDFString)(dict.get('Contents') || '');
+  }
+  loadResources(keys) {
+    return this.appearance.dict.getAsync('Resources').then(resources => {
+      if (!resources) {
+        return;
+      }
+      let objectLoader = new _obj.ObjectLoader(resources, keys, resources.xref);
+      return objectLoader.load().then(function () {
+        return resources;
+      });
+    });
+  }
+  getOperatorList(evaluator, task, renderForms) {
+    if (!this.appearance) {
+      return Promise.resolve(new _operator_list.OperatorList());
+    }
+    let data = this.data;
+    let appearanceDict = this.appearance.dict;
+    let resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']);
+    let bbox = appearanceDict.getArray('BBox') || [0, 0, 1, 1];
+    let matrix = appearanceDict.getArray('Matrix') || [1, 0, 0, 1, 0, 0];
+    let transform = getTransformMatrix(data.rect, bbox, matrix);
+    return resourcesPromise.then(resources => {
+      let opList = new _operator_list.OperatorList();
+      opList.addOp(_util.OPS.beginAnnotation, [data.rect, transform, matrix]);
+      return evaluator.getOperatorList({
+        stream: this.appearance,
+        task,
+        resources,
+        operatorList: opList
+      }).then(() => {
+        opList.addOp(_util.OPS.endAnnotation, []);
+        this.appearance.reset();
+        return opList;
+      });
+    });
+  }
+}
+class AnnotationBorderStyle {
+  constructor() {
+    this.width = 1;
+    this.style = _util.AnnotationBorderStyleType.SOLID;
+    this.dashArray = [3];
+    this.horizontalCornerRadius = 0;
+    this.verticalCornerRadius = 0;
+  }
+  setWidth(width) {
+    if (Number.isInteger(width)) {
+      this.width = width;
+    }
+  }
+  setStyle(style) {
+    if (!style) {
+      return;
+    }
+    switch (style.name) {
+      case 'S':
+        this.style = _util.AnnotationBorderStyleType.SOLID;
+        break;
+      case 'D':
+        this.style = _util.AnnotationBorderStyleType.DASHED;
+        break;
+      case 'B':
+        this.style = _util.AnnotationBorderStyleType.BEVELED;
+        break;
+      case 'I':
+        this.style = _util.AnnotationBorderStyleType.INSET;
+        break;
+      case 'U':
+        this.style = _util.AnnotationBorderStyleType.UNDERLINE;
+        break;
+      default:
+        break;
+    }
+  }
+  setDashArray(dashArray) {
+    if (Array.isArray(dashArray) && dashArray.length > 0) {
+      let isValid = true;
+      let allZeros = true;
+      for (let i = 0, len = dashArray.length; i < len; i++) {
+        let element = dashArray[i];
+        let validNumber = +element >= 0;
+        if (!validNumber) {
+          isValid = false;
+          break;
+        } else if (element > 0) {
+          allZeros = false;
+        }
+      }
+      if (isValid && !allZeros) {
+        this.dashArray = dashArray;
+      } else {
+        this.width = 0;
+      }
+    } else if (dashArray) {
+      this.width = 0;
+    }
+  }
+  setHorizontalCornerRadius(radius) {
+    if (Number.isInteger(radius)) {
+      this.horizontalCornerRadius = radius;
+    }
+  }
+  setVerticalCornerRadius(radius) {
+    if (Number.isInteger(radius)) {
+      this.verticalCornerRadius = radius;
+    }
+  }
+}
+class WidgetAnnotation extends Annotation {
+  constructor(params) {
+    super(params);
+    let dict = params.dict;
+    let data = this.data;
+    data.annotationType = _util.AnnotationType.WIDGET;
+    data.fieldName = this._constructFieldName(dict);
+    data.fieldValue = _util.Util.getInheritableProperty(dict, 'V', true);
+    data.alternativeText = (0, _util.stringToPDFString)(dict.get('TU') || '');
+    data.defaultAppearance = _util.Util.getInheritableProperty(dict, 'DA') || '';
+    let fieldType = _util.Util.getInheritableProperty(dict, 'FT');
+    data.fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null;
+    this.fieldResources = _util.Util.getInheritableProperty(dict, 'DR') || _primitives.Dict.empty;
+    data.fieldFlags = _util.Util.getInheritableProperty(dict, 'Ff');
+    if (!Number.isInteger(data.fieldFlags) || data.fieldFlags < 0) {
+      data.fieldFlags = 0;
+    }
+    data.readOnly = this.hasFieldFlag(_util.AnnotationFieldFlag.READONLY);
+    if (data.fieldType === 'Sig') {
+      this.setFlags(_util.AnnotationFlag.HIDDEN);
+    }
+  }
+  _constructFieldName(dict) {
+    if (!dict.has('T') && !dict.has('Parent')) {
+      (0, _util.warn)('Unknown field name, falling back to empty field name.');
+      return '';
+    }
+    if (!dict.has('Parent')) {
+      return (0, _util.stringToPDFString)(dict.get('T'));
+    }
+    let fieldName = [];
+    if (dict.has('T')) {
+      fieldName.unshift((0, _util.stringToPDFString)(dict.get('T')));
+    }
+    let loopDict = dict;
+    while (loopDict.has('Parent')) {
+      loopDict = loopDict.get('Parent');
+      if (!(0, _primitives.isDict)(loopDict)) {
+        break;
+      }
+      if (loopDict.has('T')) {
+        fieldName.unshift((0, _util.stringToPDFString)(loopDict.get('T')));
+      }
+    }
+    return fieldName.join('.');
+  }
+  hasFieldFlag(flag) {
+    return !!(this.data.fieldFlags & flag);
+  }
+  getOperatorList(evaluator, task, renderForms) {
+    if (renderForms) {
+      return Promise.resolve(new _operator_list.OperatorList());
+    }
+    return super.getOperatorList(evaluator, task, renderForms);
+  }
+}
+class TextWidgetAnnotation extends WidgetAnnotation {
+  constructor(params) {
+    super(params);
+    this.data.fieldValue = (0, _util.stringToPDFString)(this.data.fieldValue || '');
+    let alignment = _util.Util.getInheritableProperty(params.dict, 'Q');
+    if (!Number.isInteger(alignment) || alignment < 0 || alignment > 2) {
+      alignment = null;
+    }
+    this.data.textAlignment = alignment;
+    let maximumLength = _util.Util.getInheritableProperty(params.dict, 'MaxLen');
+    if (!Number.isInteger(maximumLength) || maximumLength < 0) {
+      maximumLength = null;
+    }
+    this.data.maxLen = maximumLength;
+    this.data.multiLine = this.hasFieldFlag(_util.AnnotationFieldFlag.MULTILINE);
+    this.data.comb = this.hasFieldFlag(_util.AnnotationFieldFlag.COMB) && !this.hasFieldFlag(_util.AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(_util.AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(_util.AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
+  }
+  getOperatorList(evaluator, task, renderForms) {
+    if (renderForms || this.appearance) {
+      return super.getOperatorList(evaluator, task, renderForms);
+    }
+    let operatorList = new _operator_list.OperatorList();
+    if (!this.data.defaultAppearance) {
+      return Promise.resolve(operatorList);
+    }
+    let stream = new _stream.Stream((0, _util.stringToBytes)(this.data.defaultAppearance));
+    return evaluator.getOperatorList({
+      stream,
+      task,
+      resources: this.fieldResources,
+      operatorList
+    }).then(function () {
+      return operatorList;
+    });
+  }
+}
+class ButtonWidgetAnnotation extends WidgetAnnotation {
+  constructor(params) {
+    super(params);
+    this.data.checkBox = !this.hasFieldFlag(_util.AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
+    if (this.data.checkBox) {
+      if (!(0, _primitives.isName)(this.data.fieldValue)) {
+        return;
+      }
+      this.data.fieldValue = this.data.fieldValue.name;
+    }
+    this.data.radioButton = this.hasFieldFlag(_util.AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
+    if (this.data.radioButton) {
+      this.data.fieldValue = this.data.buttonValue = null;
+      let fieldParent = params.dict.get('Parent');
+      if ((0, _primitives.isDict)(fieldParent) && fieldParent.has('V')) {
+        let fieldParentValue = fieldParent.get('V');
+        if ((0, _primitives.isName)(fieldParentValue)) {
+          this.data.fieldValue = fieldParentValue.name;
+        }
+      }
+      let appearanceStates = params.dict.get('AP');
+      if (!(0, _primitives.isDict)(appearanceStates)) {
+        return;
+      }
+      let normalAppearanceState = appearanceStates.get('N');
+      if (!(0, _primitives.isDict)(normalAppearanceState)) {
+        return;
+      }
+      let keys = normalAppearanceState.getKeys();
+      for (let i = 0, ii = keys.length; i < ii; i++) {
+        if (keys[i] !== 'Off') {
+          this.data.buttonValue = keys[i];
+          break;
+        }
+      }
+    }
+  }
+}
+class ChoiceWidgetAnnotation extends WidgetAnnotation {
+  constructor(params) {
+    super(params);
+    this.data.options = [];
+    let options = _util.Util.getInheritableProperty(params.dict, 'Opt');
+    if (Array.isArray(options)) {
+      let xref = params.xref;
+      for (let i = 0, ii = options.length; i < ii; i++) {
+        let option = xref.fetchIfRef(options[i]);
+        let isOptionArray = Array.isArray(option);
+        this.data.options[i] = {
+          exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
+          displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
+        };
+      }
+    }
+    if (!Array.isArray(this.data.fieldValue)) {
+      this.data.fieldValue = [this.data.fieldValue];
+    }
+    this.data.combo = this.hasFieldFlag(_util.AnnotationFieldFlag.COMBO);
+    this.data.multiSelect = this.hasFieldFlag(_util.AnnotationFieldFlag.MULTISELECT);
+  }
+}
+class TextAnnotation extends Annotation {
+  constructor(parameters) {
+    const DEFAULT_ICON_SIZE = 22;
+    super(parameters);
+    this.data.annotationType = _util.AnnotationType.TEXT;
+    if (this.data.hasAppearance) {
+      this.data.name = 'NoIcon';
+    } else {
+      this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
+      this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
+      this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
+    }
+    this._preparePopup(parameters.dict);
+  }
+}
+class LinkAnnotation extends Annotation {
+  constructor(params) {
+    super(params);
+    this.data.annotationType = _util.AnnotationType.LINK;
+    _obj.Catalog.parseDestDictionary({
+      destDict: params.dict,
+      resultObj: this.data,
+      docBaseUrl: params.pdfManager.docBaseUrl
+    });
+  }
+}
+class PopupAnnotation extends Annotation {
+  constructor(parameters) {
+    super(parameters);
+    this.data.annotationType = _util.AnnotationType.POPUP;
+    let dict = parameters.dict;
+    let parentItem = dict.get('Parent');
+    if (!parentItem) {
+      (0, _util.warn)('Popup annotation has a missing or invalid parent annotation.');
+      return;
+    }
+    let parentSubtype = parentItem.get('Subtype');
+    this.data.parentType = (0, _primitives.isName)(parentSubtype) ? parentSubtype.name : null;
+    this.data.parentId = dict.getRaw('Parent').toString();
+    this.data.title = (0, _util.stringToPDFString)(parentItem.get('T') || '');
+    this.data.contents = (0, _util.stringToPDFString)(parentItem.get('Contents') || '');
+    if (!parentItem.has('C')) {
+      this.data.color = null;
+    } else {
+      this.setColor(parentItem.getArray('C'));
+      this.data.color = this.color;
+    }
+    if (!this.viewable) {
+      let parentFlags = parentItem.get('F');
+      if (this._isViewable(parentFlags)) {
+        this.setFlags(parentFlags);
+      }
+    }
+  }
+}
+class LineAnnotation extends Annotation {
+  constructor(parameters) {
+    super(parameters);
+    this.data.annotationType = _util.AnnotationType.LINE;
+    let dict = parameters.dict;
+    this.data.lineCoordinates = _util.Util.normalizeRect(dict.getArray('L'));
+    this._preparePopup(dict);
+  }
+}
+class SquareAnnotation extends Annotation {
+  constructor(parameters) {
+    super(parameters);
+    this.data.annotationType = _util.AnnotationType.SQUARE;
+    this._preparePopup(parameters.dict);
+  }
+}
+class CircleAnnotation extends Annotation {
+  constructor(parameters) {
+    super(parameters);
+    this.data.annotationType = _util.AnnotationType.CIRCLE;
+    this._preparePopup(parameters.dict);
+  }
+}
+class PolylineAnnotation extends Annotation {
+  constructor(parameters) {
+    super(parameters);
+    this.data.annotationType = _util.AnnotationType.POLYLINE;
+    let dict = parameters.dict;
+    let rawVertices = dict.getArray('Vertices');
+    this.data.vertices = [];
+    for (let i = 0, ii = rawVertices.length; i < ii; i += 2) {
+      this.data.vertices.push({
+        x: rawVertices[i],
+        y: rawVertices[i + 1]
+      });
+    }
+    this._preparePopup(dict);
+  }
+}
+class PolygonAnnotation extends PolylineAnnotation {
+  constructor(parameters) {
+    super(parameters);
+    this.data.annotationType = _util.AnnotationType.POLYGON;
+  }
+}
+class HighlightAnnotation extends Annotation {
+  constructor(parameters) {
+    super(parameters);
+    this.data.annotationType = _util.AnnotationType.HIGHLIGHT;
+    this._preparePopup(parameters.dict);
+  }
+}
+class UnderlineAnnotation extends Annotation {
+  constructor(parameters) {
+    super(parameters);
+    this.data.annotationType = _util.AnnotationType.UNDERLINE;
+    this._preparePopup(parameters.dict);
+  }
+}
+class SquigglyAnnotation extends Annotation {
+  constructor(parameters) {
+    super(parameters);
+    this.data.annotationType = _util.AnnotationType.SQUIGGLY;
+    this._preparePopup(parameters.dict);
+  }
+}
+class StrikeOutAnnotation extends Annotation {
+  constructor(parameters) {
+    super(parameters);
+    this.data.annotationType = _util.AnnotationType.STRIKEOUT;
+    this._preparePopup(parameters.dict);
+  }
+}
+class StampAnnotation extends Annotation {
+  constructor(parameters) {
+    super(parameters);
+    this.data.annotationType = _util.AnnotationType.STAMP;
+    this._preparePopup(parameters.dict);
+  }
+}
+class FileAttachmentAnnotation extends Annotation {
+  constructor(parameters) {
+    super(parameters);
+    let file = new _obj.FileSpec(parameters.dict.get('FS'), parameters.xref);
+    this.data.annotationType = _util.AnnotationType.FILEATTACHMENT;
+    this.data.file = file.serializable;
+    this._preparePopup(parameters.dict);
+  }
+}
+exports.Annotation = Annotation;
+exports.AnnotationBorderStyle = AnnotationBorderStyle;
+exports.AnnotationFactory = AnnotationFactory;
+
+/***/ }),
+/* 30 */
+/***/ (function(module, exports, __w_pdfjs_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.PartialEvaluator = undefined;
+
+var _util = __w_pdfjs_require__(0);
+
+var _cmap = __w_pdfjs_require__(31);
+
+var _stream = __w_pdfjs_require__(2);
+
+var _primitives = __w_pdfjs_require__(1);
+
+var _fonts = __w_pdfjs_require__(32);
+
+var _encodings = __w_pdfjs_require__(4);
+
+var _unicode = __w_pdfjs_require__(15);
+
+var _standard_fonts = __w_pdfjs_require__(14);
+
+var _pattern = __w_pdfjs_require__(36);
+
+var _parser = __w_pdfjs_require__(5);
+
+var _bidi = __w_pdfjs_require__(37);
+
+var _colorspace = __w_pdfjs_require__(3);
+
+var _glyphlist = __w_pdfjs_require__(7);
+
+var _metrics = __w_pdfjs_require__(38);
+
+var _function = __w_pdfjs_require__(16);
+
+var _murmurhash = __w_pdfjs_require__(40);
+
+var _operator_list = __w_pdfjs_require__(6);
+
+var _image = __w_pdfjs_require__(41);
+
+var PartialEvaluator = function PartialEvaluatorClosure() {
+  const DefaultPartialEvaluatorOptions = {
+    forceDataSchema: false,
+    maxImageSize: -1,
+    disableFontFace: false,
+    nativeImageDecoderSupport: _util.NativeImageDecoding.DECODE,
+    ignoreErrors: false,
+    isEvalSupported: true
+  };
+  function NativeImageDecoder({ xref, resources, handler, forceDataSchema = false, pdfFunctionFactory }) {
+    this.xref = xref;
+    this.resources = resources;
+    this.handler = handler;
+    this.forceDataSchema = forceDataSchema;
+    this.pdfFunctionFactory = pdfFunctionFactory;
+  }
+  NativeImageDecoder.prototype = {
+    canDecode(image) {
+      return image instanceof _stream.JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources, this.pdfFunctionFactory);
+    },
+    decode(image) {
+      var dict = image.dict;
+      var colorSpace = dict.get('ColorSpace', 'CS');
+      colorSpace = _colorspace.ColorSpace.parse(colorSpace, this.xref, this.resources, this.pdfFunctionFactory);
+      var numComps = colorSpace.numComps;
+      var decodePromise = this.handler.sendWithPromise('JpegDecode', [image.getIR(this.forceDataSchema), numComps]);
+      return decodePromise.then(function (message) {
+        var data = message.data;
+        return new _stream.Stream(data, 0, data.length, image.dict);
+      });
+    }
+  };
+  NativeImageDecoder.isSupported = function (image, xref, res, pdfFunctionFactory) {
+    var dict = image.dict;
+    if (dict.has('DecodeParms') || dict.has('DP')) {
+      return false;
+    }
+    var cs = _colorspace.ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res, pdfFunctionFactory);
+    return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
+  };
+  NativeImageDecoder.isDecodable = function (image, xref, res, pdfFunctionFactory) {
+    var dict = image.dict;
+    if (dict.has('DecodeParms') || dict.has('DP')) {
+      return false;
+    }
+    var cs = _colorspace.ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res, pdfFunctionFactory);
+    return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
+  };
+  function PartialEvaluator({ pdfManager, xref, handler, pageIndex, idFactory, fontCache, builtInCMapCache, options = null, pdfFunctionFactory }) {
+    this.pdfManager = pdfManager;
+    this.xref = xref;
+    this.handler = handler;
+    this.pageIndex = pageIndex;
+    this.idFactory = idFactory;
+    this.fontCache = fontCache;
+    this.builtInCMapCache = builtInCMapCache;
+    this.options = options || DefaultPartialEvaluatorOptions;
+    this.pdfFunctionFactory = pdfFunctionFactory;
+    this.fetchBuiltInCMap = name => {
+      var cachedCMap = this.builtInCMapCache[name];
+      if (cachedCMap) {
+        return Promise.resolve(cachedCMap);
+      }
+      return this.handler.sendWithPromise('FetchBuiltInCMap', { name }).then(data => {
+        if (data.compressionType !== _util.CMapCompressionType.NONE) {
+          this.builtInCMapCache[name] = data;
+        }
+        return data;
+      });
+    };
+  }
+  var TIME_SLOT_DURATION_MS = 20;
+  var CHECK_TIME_EVERY = 100;
+  function TimeSlotManager() {
+    this.reset();
+  }
+  TimeSlotManager.prototype = {
+    check: function TimeSlotManager_check() {
+      if (++this.checked < CHECK_TIME_EVERY) {
+        return false;
+      }
+      this.checked = 0;
+      return this.endTime <= Date.now();
+    },
+    reset: function TimeSlotManager_reset() {
+      this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
+      this.checked = 0;
+    }
+  };
+  function normalizeBlendMode(value) {
+    if (!(0, _primitives.isName)(value)) {
+      return 'source-over';
+    }
+    switch (value.name) {
+      case 'Normal':
+      case 'Compatible':
+        return 'source-over';
+      case 'Multiply':
+        return 'multiply';
+      case 'Screen':
+        return 'screen';
+      case 'Overlay':
+        return 'overlay';
+      case 'Darken':
+        return 'darken';
+      case 'Lighten':
+        return 'lighten';
+      case 'ColorDodge':
+        return 'color-dodge';
+      case 'ColorBurn':
+        return 'color-burn';
+      case 'HardLight':
+        return 'hard-light';
+      case 'SoftLight':
+        return 'soft-light';
+      case 'Difference':
+        return 'difference';
+      case 'Exclusion':
+        return 'exclusion';
+      case 'Hue':
+        return 'hue';
+      case 'Saturation':
+        return 'saturation';
+      case 'Color':
+        return 'color';
+      case 'Luminosity':
+        return 'luminosity';
+    }
+    (0, _util.warn)('Unsupported blend mode: ' + value.name);
+    return 'source-over';
+  }
+  var deferred = Promise.resolve();
+  var TILING_PATTERN = 1,
+      SHADING_PATTERN = 2;
+  PartialEvaluator.prototype = {
+    clone(newOptions = DefaultPartialEvaluatorOptions) {
+      var newEvaluator = Object.create(this);
+      newEvaluator.options = newOptions;
+      return newEvaluator;
+    },
+    hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
+      if (!(0, _primitives.isDict)(resources)) {
+        return false;
+      }
+      var processed = Object.create(null);
+      if (resources.objId) {
+        processed[resources.objId] = true;
+      }
+      var nodes = [resources],
+          xref = this.xref;
+      while (nodes.length) {
+        var key, i, ii;
+        var node = nodes.shift();
+        var graphicStates = node.get('ExtGState');
+        if ((0, _primitives.isDict)(graphicStates)) {
+          var graphicStatesKeys = graphicStates.getKeys();
+          for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
+            key = graphicStatesKeys[i];
+            var graphicState = graphicStates.get(key);
+            var bm = graphicState.get('BM');
+            if ((0, _primitives.isName)(bm) && bm.name !== 'Normal') {
+              return true;
+            }
+          }
+        }
+        var xObjects = node.get('XObject');
+        if (!(0, _primitives.isDict)(xObjects)) {
+          continue;
+        }
+        var xObjectsKeys = xObjects.getKeys();
+        for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
+          key = xObjectsKeys[i];
+          var xObject = xObjects.getRaw(key);
+          if ((0, _primitives.isRef)(xObject)) {
+            if (processed[xObject.toString()]) {
+              continue;
+            }
+            xObject = xref.fetch(xObject);
+          }
+          if (!(0, _primitives.isStream)(xObject)) {
+            continue;
+          }
+          if (xObject.dict.objId) {
+            if (processed[xObject.dict.objId]) {
+              continue;
+            }
+            processed[xObject.dict.objId] = true;
+          }
+          var xResources = xObject.dict.get('Resources');
+          if ((0, _primitives.isDict)(xResources) && (!xResources.objId || !processed[xResources.objId])) {
+            nodes.push(xResources);
+            if (xResources.objId) {
+              processed[xResources.objId] = true;
+            }
+          }
+        }
+      }
+      return false;
+    },
+    buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
+      var dict = xobj.dict;
+      var matrix = dict.getArray('Matrix');
+      var bbox = dict.getArray('BBox');
+      var group = dict.get('Group');
+      if (group) {
+        var groupOptions = {
+          matrix,
+          bbox,
+          smask,
+          isolated: false,
+          knockout: false
+        };
+        var groupSubtype = group.get('S');
+        var colorSpace = null;
+        if ((0, _primitives.isName)(groupSubtype, 'Transparency')) {
+          groupOptions.isolated = group.get('I') || false;
+          groupOptions.knockout = group.get('K') || false;
+          if (group.has('CS')) {
+            colorSpace = _colorspace.ColorSpace.parse(group.get('CS'), this.xref, resources, this.pdfFunctionFactory);
+          }
+        }
+        if (smask && smask.backdrop) {
+          colorSpace = colorSpace || _colorspace.ColorSpace.singletons.rgb;
+          smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
+        }
+        operatorList.addOp(_util.OPS.beginGroup, [groupOptions]);
+      }
+      operatorList.addOp(_util.OPS.paintFormXObjectBegin, [matrix, bbox]);
+      return this.getOperatorList({
+        stream: xobj,
+        task,
+        resources: dict.get('Resources') || resources,
+        operatorList,
+        initialState
+      }).then(function () {
+        operatorList.addOp(_util.OPS.paintFormXObjectEnd, []);
+        if (group) {
+          operatorList.addOp(_util.OPS.endGroup, [groupOptions]);
+        }
+      });
+    },
+    buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
+      var dict = image.dict;
+      var w = dict.get('Width', 'W');
+      var h = dict.get('Height', 'H');
+      if (!(w && (0, _util.isNum)(w)) || !(h && (0, _util.isNum)(h))) {
+        (0, _util.warn)('Image dimensions are missing, or not numbers.');
+        return;
+      }
+      var maxImageSize = this.options.maxImageSize;
+      if (maxImageSize !== -1 && w * h > maxImageSize) {
+        (0, _util.warn)('Image exceeded maximum allowed size and was removed.');
+        return;
+      }
+      var imageMask = dict.get('ImageMask', 'IM') || false;
+      var imgData, args;
+      if (imageMask) {
+        var width = dict.get('Width', 'W');
+        var height = dict.get('Height', 'H');
+        var bitStrideLength = width + 7 >> 3;
+        var imgArray = image.getBytes(bitStrideLength * height);
+        var decode = dict.getArray('Decode', 'D');
+        imgData = _image.PDFImage.createMask({
+          imgArray,
+          width,
+          height,
+          imageIsFromDecodeStream: image instanceof _stream.DecodeStream,
+          inverseDecode: !!decode && decode[0] > 0
+        });
+        imgData.cached = true;
+        args = [imgData];
+        operatorList.addOp(_util.OPS.paintImageMaskXObject, args);
+        if (cacheKey) {
+          imageCache[cacheKey] = {
+            fn: _util.OPS.paintImageMaskXObject,
+            args
+          };
+        }
+        return;
+      }
+      var softMask = dict.get('SMask', 'SM') || false;
+      var mask = dict.get('Mask') || false;
+      var SMALL_IMAGE_DIMENSIONS = 200;
+      if (inline && !softMask && !mask && !(image instanceof _stream.JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
+        let imageObj = new _image.PDFImage({
+          xref: this.xref,
+          res: resources,
+          image,
+          pdfFunctionFactory: this.pdfFunctionFactory
+        });
+        imgData = imageObj.createImageData(true);
+        operatorList.addOp(_util.OPS.paintInlineImageXObject, [imgData]);
+        return;
+      }
+      var nativeImageDecoderSupport = this.options.nativeImageDecoderSupport;
+      var objId = 'img_' + this.idFactory.createObjId();
+      operatorList.addDependency(objId);
+      args = [objId, w, h];
+      if (nativeImageDecoderSupport !== _util.NativeImageDecoding.NONE && !softMask && !mask && image instanceof _stream.JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources, this.pdfFunctionFactory)) {
+        operatorList.addOp(_util.OPS.paintJpegXObject, args);
+        this.handler.send('obj', [objId, this.pageIndex, 'JpegStream', image.getIR(this.options.forceDataSchema)]);
+        if (cacheKey) {
+          imageCache[cacheKey] = {
+            fn: _util.OPS.paintJpegXObject,
+            args
+          };
+        }
+        return;
+      }
+      var nativeImageDecoder = null;
+      if (nativeImageDecoderSupport === _util.NativeImageDecoding.DECODE && (image instanceof _stream.JpegStream || mask instanceof _stream.JpegStream || softMask instanceof _stream.JpegStream)) {
+        nativeImageDecoder = new NativeImageDecoder({
+          xref: this.xref,
+          resources,
+          handler: this.handler,
+          forceDataSchema: this.options.forceDataSchema,
+          pdfFunctionFactory: this.pdfFunctionFactory
+        });
+      }
+      _image.PDFImage.buildImage({
+        handler: this.handler,
+        xref: this.xref,
+        res: resources,
+        image,
+        nativeDecoder: nativeImageDecoder,
+        pdfFunctionFactory: this.pdfFunctionFactory
+      }).then(imageObj => {
+        var imgData = imageObj.createImageData(false);
+        this.handler.send('obj', [objId, this.pageIndex, 'Image', imgData], [imgData.data.buffer]);
+      }).catch(reason => {
+        (0, _util.warn)('Unable to decode image: ' + reason);
+        this.handler.send('obj', [objId, this.pageIndex, 'Image', null]);
+      });
+      operatorList.addOp(_util.OPS.paintImageXObject, args);
+      if (cacheKey) {
+        imageCache[cacheKey] = {
+          fn: _util.OPS.paintImageXObject,
+          args
+        };
+      }
+    },
+    handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
+      var smaskContent = smask.get('G');
+      var smaskOptions = {
+        subtype: smask.get('S').name,
+        backdrop: smask.get('BC')
+      };
+      var transferObj = smask.get('TR');
+      if ((0, _function.isPDFFunction)(transferObj)) {
+        let transferFn = this.pdfFunctionFactory.create(transferObj);
+        var transferMap = new Uint8Array(256);
+        var tmp = new Float32Array(1);
+        for (var i = 0; i < 256; i++) {
+          tmp[0] = i / 255;
+          transferFn(tmp, 0, tmp, 0);
+          transferMap[i] = tmp[0] * 255 | 0;
+        }
+        smaskOptions.transferMap = transferMap;
+      }
+      return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
+    },
+    handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
+      let tilingOpList = new _operator_list.OperatorList();
+      let resourcesArray = [patternDict.get('Resources'), resources];
+      let patternResources = _primitives.Dict.merge(this.xref, resourcesArray);
+      return this.getOperatorList({
+        stream: pattern,
+        task,
+        resources: patternResources,
+        operatorList: tilingOpList
+      }).then(function () {
+        return (0, _pattern.getTilingPatternIR)({
+          fnArray: tilingOpList.fnArray,
+          argsArray: tilingOpList.argsArray
+        }, patternDict, args);
+      }).then(function (tilingPatternIR) {
+        operatorList.addDependencies(tilingOpList.dependencies);
+        operatorList.addOp(fn, tilingPatternIR);
+      }, reason => {
+        if (this.options.ignoreErrors) {
+          this.handler.send('UnsupportedFeature', { featureId: _util.UNSUPPORTED_FEATURES.unknown });
+          (0, _util.warn)(`handleTilingType - ignoring pattern: "${reason}".`);
+          return;
+        }
+        throw reason;
+      });
+    },
+    handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
+      var fontName;
+      if (fontArgs) {
+        fontArgs = fontArgs.slice();
+        fontName = fontArgs[0].name;
+      }
+      return this.loadFont(fontName, fontRef, resources).then(translated => {
+        if (!translated.font.isType3Font) {
+          return translated;
+        }
+        return translated.loadType3Data(this, resources, operatorList, task).then(function () {
+          return translated;
+        }).catch(reason => {
+          this.handler.send('UnsupportedFeature', { featureId: _util.UNSUPPORTED_FEATURES.font });
+          return new TranslatedFont('g_font_error', new _fonts.ErrorFont('Type3 font load error: ' + reason), translated.font);
+        });
+      }).then(translated => {
+        state.font = translated.font;
+        translated.send(this.handler);
+        return translated.loadedName;
+      });
+    },
+    handleText: function PartialEvaluator_handleText(chars, state) {
+      var font = state.font;
+      var glyphs = font.charsToGlyphs(chars);
+      var isAddToPathSet = !!(state.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
+      if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
+        var buildPath = fontChar => {
+          if (!font.renderer.hasBuiltPath(fontChar)) {
+            var path = font.renderer.getPathJs(fontChar);
+            this.handler.send('commonobj', [font.loadedName + '_path_' + fontChar, 'FontPath', path]);
+          }
+        };
+        for (var i = 0, ii = glyphs.length; i < ii; i++) {
+          var glyph = glyphs[i];
+          buildPath(glyph.fontChar);
+          var accent = glyph.accent;
+          if (accent && accent.fontChar) {
+            buildPath(accent.fontChar);
+          }
+        }
+      }
+      return glyphs;
+    },
+    setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, stateManager) {
+      var gStateObj = [];
+      var gStateKeys = gState.getKeys();
+      var promise = Promise.resolve();
+      for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
+        let key = gStateKeys[i];
+        let value = gState.get(key);
+        switch (key) {
+          case 'Type':
+            break;
+          case 'LW':
+          case 'LC':
+          case 'LJ':
+          case 'ML':
+          case 'D':
+          case 'RI':
+          case 'FL':
+          case 'CA':
+          case 'ca':
+            gStateObj.push([key, value]);
+            break;
+          case 'Font':
+            promise = promise.then(() => {
+              return this.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
+                operatorList.addDependency(loadedName);
+                gStateObj.push([key, [loadedName, value[1]]]);
+              });
+            });
+            break;
+          case 'BM':
+            gStateObj.push([key, normalizeBlendMode(value)]);
+            break;
+          case 'SMask':
+            if ((0, _primitives.isName)(value, 'None')) {
+              gStateObj.push([key, false]);
+              break;
+            }
+            if ((0, _primitives.isDict)(value)) {
+              promise = promise.then(() => {
+                return this.handleSMask(value, resources, operatorList, task, stateManager);
+              });
+              gStateObj.push([key, true]);
+            } else {
+              (0, _util.warn)('Unsupported SMask type');
+            }
+            break;
+          case 'OP':
+          case 'op':
+          case 'OPM':
+          case 'BG':
+          case 'BG2':
+          case 'UCR':
+          case 'UCR2':
+          case 'TR':
+          case 'TR2':
+          case 'HT':
+          case 'SM':
+          case 'SA':
+          case 'AIS':
+          case 'TK':
+            (0, _util.info)('graphic state operator ' + key);
+            break;
+          default:
+            (0, _util.info)('Unknown graphic state operator ' + key);
+            break;
+        }
+      }
+      return promise.then(function () {
+        if (gStateObj.length > 0) {
+          operatorList.addOp(_util.OPS.setGState, [gStateObj]);
+        }
+      });
+    },
+    loadFont: function PartialEvaluator_loadFont(fontName, font, resources) {
+      function errorFont() {
+        return Promise.resolve(new TranslatedFont('g_font_error', new _fonts.ErrorFont('Font ' + fontName + ' is not available'), font));
+      }
+      var fontRef,
+          xref = this.xref;
+      if (font) {
+        if (!(0, _primitives.isRef)(font)) {
+          throw new Error('The "font" object should be a reference.');
+        }
+        fontRef = font;
+      } else {
+        var fontRes = resources.get('Font');
+        if (fontRes) {
+          fontRef = fontRes.getRaw(fontName);
+        } else {
+          (0, _util.warn)('fontRes not available');
+          return errorFont();
+        }
+      }
+      if (!fontRef) {
+        (0, _util.warn)('fontRef not available');
+        return errorFont();
+      }
+      if (this.fontCache.has(fontRef)) {
+        return this.fontCache.get(fontRef);
+      }
+      font = xref.fetchIfRef(fontRef);
+      if (!(0, _primitives.isDict)(font)) {
+        return errorFont();
+      }
+      if (font.translated) {
+        return font.translated;
+      }
+      var fontCapability = (0, _util.createPromiseCapability)();
+      var preEvaluatedFont = this.preEvaluateFont(font);
+      var descriptor = preEvaluatedFont.descriptor;
+      var fontRefIsRef = (0, _primitives.isRef)(fontRef),
+          fontID;
+      if (fontRefIsRef) {
+        fontID = fontRef.toString();
+      }
+      if ((0, _primitives.isDict)(descriptor)) {
+        if (!descriptor.fontAliases) {
+          descriptor.fontAliases = Object.create(null);
+        }
+        var fontAliases = descriptor.fontAliases;
+        var hash = preEvaluatedFont.hash;
+        if (fontAliases[hash]) {
+          var aliasFontRef = fontAliases[hash].aliasRef;
+          if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
+            this.fontCache.putAlias(fontRef, aliasFontRef);
+            return this.fontCache.get(fontRef);
+          }
+        } else {
+          fontAliases[hash] = { fontID: _fonts.Font.getFontID() };
+        }
+        if (fontRefIsRef) {
+          fontAliases[hash].aliasRef = fontRef;
+        }
+        fontID = fontAliases[hash].fontID;
+      }
+      if (fontRefIsRef) {
+        this.fontCache.put(fontRef, fontCapability.promise);
+      } else {
+        if (!fontID) {
+          fontID = this.idFactory.createObjId();
+        }
+        this.fontCache.put('id_' + fontID, fontCapability.promise);
+      }
+      (0, _util.assert)(fontID, 'The "fontID" must be defined.');
+      font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
+      font.translated = fontCapability.promise;
+      var translatedPromise;
+      try {
+        translatedPromise = this.translateFont(preEvaluatedFont);
+      } catch (e) {
+        translatedPromise = Promise.reject(e);
+      }
+      translatedPromise.then(function (translatedFont) {
+        if (translatedFont.fontType !== undefined) {
+          var xrefFontStats = xref.stats.fontTypes;
+          xrefFontStats[translatedFont.fontType] = true;
+        }
+        fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
+      }).catch(reason => {
+        this.handler.send('UnsupportedFeature', { featureId: _util.UNSUPPORTED_FEATURES.font });
+        try {
+          var descriptor = preEvaluatedFont.descriptor;
+          var fontFile3 = descriptor && descriptor.get('FontFile3');
+          var subtype = fontFile3 && fontFile3.get('Subtype');
+          var fontType = (0, _fonts.getFontType)(preEvaluatedFont.type, subtype && subtype.name);
+          var xrefFontStats = xref.stats.fontTypes;
+          xrefFontStats[fontType] = true;
+        } catch (ex) {}
+        fontCapability.resolve(new TranslatedFont(font.loadedName, new _fonts.ErrorFont(reason instanceof Error ? reason.message : reason), font));
+      });
+      return fontCapability.promise;
+    },
+    buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
+      var lastIndex = operatorList.length - 1;
+      if (!args) {
+        args = [];
+      }
+      if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== _util.OPS.constructPath) {
+        operatorList.addOp(_util.OPS.constructPath, [[fn], args]);
+      } else {
+        var opArgs = operatorList.argsArray[lastIndex];
+        opArgs[0].push(fn);
+        Array.prototype.push.apply(opArgs[1], args);
+      }
+    },
+    handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task) {
+      var patternName = args[args.length - 1];
+      var pattern;
+      if ((0, _primitives.isName)(patternName) && (pattern = patterns.get(patternName.name))) {
+        var dict = (0, _primitives.isStream)(pattern) ? pattern.dict : pattern;
+        var typeNum = dict.get('PatternType');
+        if (typeNum === TILING_PATTERN) {
+          var color = cs.base ? cs.base.getRgb(args, 0) : null;
+          return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
+        } else if (typeNum === SHADING_PATTERN) {
+          var shading = dict.get('Shading');
+          var matrix = dict.getArray('Matrix');
+          pattern = _pattern.Pattern.parseShading(shading, matrix, this.xref, resources, this.handler, this.pdfFunctionFactory);
+          operatorList.addOp(fn, pattern.getIR());
+          return Promise.resolve();
+        }
+        return Promise.reject(new Error('Unknown PatternType: ' + typeNum));
+      }
+      operatorList.addOp(fn, args);
+      return Promise.resolve();
+    },
+    getOperatorList({ stream, task, resources, operatorList, initialState = null }) {
+      resources = resources || _primitives.Dict.empty;
+      initialState = initialState || new EvalState();
+      if (!operatorList) {
+        throw new Error('getOperatorList: missing "operatorList" parameter');
+      }
+      var self = this;
+      var xref = this.xref;
+      var imageCache = Object.create(null);
+      var xobjs = resources.get('XObject') || _primitives.Dict.empty;
+      var patterns = resources.get('Pattern') || _primitives.Dict.empty;
+      var stateManager = new StateManager(initialState);
+      var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
+      var timeSlotManager = new TimeSlotManager();
+      function closePendingRestoreOPS(argument) {
+        for (var i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
+          operatorList.addOp(_util.OPS.restore, []);
+        }
+      }
+      return new Promise(function promiseBody(resolve, reject) {
+        var next = function (promise) {
+          promise.then(function () {
+            try {
+              promiseBody(resolve, reject);
+            } catch (ex) {
+              reject(ex);
+            }
+          }, reject);
+        };
+        task.ensureNotTerminated();
+        timeSlotManager.reset();
+        var stop,
+            operation = {},
+            i,
+            ii,
+            cs;
+        while (!(stop = timeSlotManager.check())) {
+          operation.args = null;
+          if (!preprocessor.read(operation)) {
+            break;
+          }
+          var args = operation.args;
+          var fn = operation.fn;
+          switch (fn | 0) {
+            case _util.OPS.paintXObject:
+              var name = args[0].name;
+              if (name && imageCache[name] !== undefined) {
+                operatorList.addOp(imageCache[name].fn, imageCache[name].args);
+                args = null;
+                continue;
+              }
+              next(new Promise(function (resolveXObject, rejectXObject) {
+                if (!name) {
+                  throw new _util.FormatError('XObject must be referred to by name.');
+                }
+                let xobj = xobjs.get(name);
+                if (!xobj) {
+                  operatorList.addOp(fn, args);
+                  resolveXObject();
+                  return;
+                }
+                if (!(0, _primitives.isStream)(xobj)) {
+                  throw new _util.FormatError('XObject should be a stream');
+                }
+                let type = xobj.dict.get('Subtype');
+                if (!(0, _primitives.isName)(type)) {
+                  throw new _util.FormatError('XObject should have a Name subtype');
+                }
+                if (type.name === 'Form') {
+                  stateManager.save();
+                  self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
+                    stateManager.restore();
+                    resolveXObject();
+                  }, rejectXObject);
+                  return;
+                } else if (type.name === 'Image') {
+                  self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
+                } else if (type.name === 'PS') {
+                  (0, _util.info)('Ignored XObject subtype PS');
+                } else {
+                  throw new _util.FormatError(`Unhandled XObject subtype ${type.name}`);
+                }
+                resolveXObject();
+              }).catch(function (reason) {
+                if (self.options.ignoreErrors) {
+                  self.handler.send('UnsupportedFeature', { featureId: _util.UNSUPPORTED_FEATURES.unknown });
+                  (0, _util.warn)(`getOperatorList - ignoring XObject: "${reason}".`);
+                  return;
+                }
+                throw reason;
+              }));
+              return;
+            case _util.OPS.setFont:
+              var fontSize = args[1];
+              next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
+                operatorList.addDependency(loadedName);
+                operatorList.addOp(_util.OPS.setFont, [loadedName, fontSize]);
+              }));
+              return;
+            case _util.OPS.endInlineImage:
+              var cacheKey = args[0].cacheKey;
+              if (cacheKey) {
+                var cacheEntry = imageCache[cacheKey];
+                if (cacheEntry !== undefined) {
+                  operatorList.addOp(cacheEntry.fn, cacheEntry.args);
+                  args = null;
+                  continue;
+                }
+              }
+              self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
+              args = null;
+              continue;
+            case _util.OPS.showText:
+              args[0] = self.handleText(args[0], stateManager.state);
+              break;
+            case _util.OPS.showSpacedText:
+              var arr = args[0];
+              var combinedGlyphs = [];
+              var arrLength = arr.length;
+              var state = stateManager.state;
+              for (i = 0; i < arrLength; ++i) {
+                var arrItem = arr[i];
+                if ((0, _util.isString)(arrItem)) {
+                  Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
+                } else if ((0, _util.isNum)(arrItem)) {
+                  combinedGlyphs.push(arrItem);
+                }
+              }
+              args[0] = combinedGlyphs;
+              fn = _util.OPS.showText;
+              break;
+            case _util.OPS.nextLineShowText:
+              operatorList.addOp(_util.OPS.nextLine);
+              args[0] = self.handleText(args[0], stateManager.state);
+              fn = _util.OPS.showText;
+              break;
+            case _util.OPS.nextLineSetSpacingShowText:
+              operatorList.addOp(_util.OPS.nextLine);
+              operatorList.addOp(_util.OPS.setWordSpacing, [args.shift()]);
+              operatorList.addOp(_util.OPS.setCharSpacing, [args.shift()]);
+              args[0] = self.handleText(args[0], stateManager.state);
+              fn = _util.OPS.showText;
+              break;
+            case _util.OPS.setTextRenderingMode:
+              stateManager.state.textRenderingMode = args[0];
+              break;
+            case _util.OPS.setFillColorSpace:
+              stateManager.state.fillColorSpace = _colorspace.ColorSpace.parse(args[0], xref, resources, self.pdfFunctionFactory);
+              continue;
+            case _util.OPS.setStrokeColorSpace:
+              stateManager.state.strokeColorSpace = _colorspace.ColorSpace.parse(args[0], xref, resources, self.pdfFunctionFactory);
+              continue;
+            case _util.OPS.setFillColor:
+              cs = stateManager.state.fillColorSpace;
+              args = cs.getRgb(args, 0);
+              fn = _util.OPS.setFillRGBColor;
+              break;
+            case _util.OPS.setStrokeColor:
+              cs = stateManager.state.strokeColorSpace;
+              args = cs.getRgb(args, 0);
+              fn = _util.OPS.setStrokeRGBColor;
+              break;
+            case _util.OPS.setFillGray:
+              stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.gray;
+              args = _colorspace.ColorSpace.singletons.gray.getRgb(args, 0);
+              fn = _util.OPS.setFillRGBColor;
+              break;
+            case _util.OPS.setStrokeGray:
+              stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.gray;
+              args = _colorspace.ColorSpace.singletons.gray.getRgb(args, 0);
+              fn = _util.OPS.setStrokeRGBColor;
+              break;
+            case _util.OPS.setFillCMYKColor:
+              stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.cmyk;
+              args = _colorspace.ColorSpace.singletons.cmyk.getRgb(args, 0);
+              fn = _util.OPS.setFillRGBColor;
+              break;
+            case _util.OPS.setStrokeCMYKColor:
+              stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.cmyk;
+              args = _colorspace.ColorSpace.singletons.cmyk.getRgb(args, 0);
+              fn = _util.OPS.setStrokeRGBColor;
+              break;
+            case _util.OPS.setFillRGBColor:
+              stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.rgb;
+              args = _colorspace.ColorSpace.singletons.rgb.getRgb(args, 0);
+              break;
+            case _util.OPS.setStrokeRGBColor:
+              stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.rgb;
+              args = _colorspace.ColorSpace.singletons.rgb.getRgb(args, 0);
+              break;
+            case _util.OPS.setFillColorN:
+              cs = stateManager.state.fillColorSpace;
+              if (cs.name === 'Pattern') {
+                next(self.handleColorN(operatorList, _util.OPS.setFillColorN, args, cs, patterns, resources, task));
+                return;
+              }
+              args = cs.getRgb(args, 0);
+              fn = _util.OPS.setFillRGBColor;
+              break;
+            case _util.OPS.setStrokeColorN:
+              cs = stateManager.state.strokeColorSpace;
+              if (cs.name === 'Pattern') {
+                next(self.handleColorN(operatorList, _util.OPS.setStrokeColorN, args, cs, patterns, resources, task));
+                return;
+              }
+              args = cs.getRgb(args, 0);
+              fn = _util.OPS.setStrokeRGBColor;
+              break;
+            case _util.OPS.shadingFill:
+              var shadingRes = resources.get('Shading');
+              if (!shadingRes) {
+                throw new _util.FormatError('No shading resource found');
+              }
+              var shading = shadingRes.get(args[0].name);
+              if (!shading) {
+                throw new _util.FormatError('No shading object found');
+              }
+              var shadingFill = _pattern.Pattern.parseShading(shading, null, xref, resources, self.handler, self.pdfFunctionFactory);
+              var patternIR = shadingFill.getIR();
+              args = [patternIR];
+              fn = _util.OPS.shadingFill;
+              break;
+            case _util.OPS.setGState:
+              var dictName = args[0];
+              var extGState = resources.get('ExtGState');
+              if (!(0, _primitives.isDict)(extGState) || !extGState.has(dictName.name)) {
+                break;
+              }
+              var gState = extGState.get(dictName.name);
+              next(self.setGState(resources, gState, operatorList, task, stateManager));
+              return;
+            case _util.OPS.moveTo:
+            case _util.OPS.lineTo:
+            case _util.OPS.curveTo:
+            case _util.OPS.curveTo2:
+            case _util.OPS.curveTo3:
+            case _util.OPS.closePath:
+              self.buildPath(operatorList, fn, args);
+              continue;
+            case _util.OPS.rectangle:
+              self.buildPath(operatorList, fn, args);
+              continue;
+            case _util.OPS.markPoint:
+            case _util.OPS.markPointProps:
+            case _util.OPS.beginMarkedContent:
+            case _util.OPS.beginMarkedContentProps:
+            case _util.OPS.endMarkedContent:
+            case _util.OPS.beginCompat:
+            case _util.OPS.endCompat:
+              continue;
+            default:
+              if (args !== null) {
+                for (i = 0, ii = args.length; i < ii; i++) {
+                  if (args[i] instanceof _primitives.Dict) {
+                    break;
+                  }
+                }
+                if (i < ii) {
+                  (0, _util.warn)('getOperatorList - ignoring operator: ' + fn);
+                  continue;
+                }
+              }
+          }
+          operatorList.addOp(fn, args);
+        }
+        if (stop) {
+          next(deferred);
+          return;
+        }
+        closePendingRestoreOPS();
+        resolve();
+      }).catch(reason => {
+        if (this.options.ignoreErrors) {
+          this.handler.send('UnsupportedFeature', { featureId: _util.UNSUPPORTED_FEATURES.unknown });
+          (0, _util.warn)('getOperatorList - ignoring errors during task: ' + task.name);
+          closePendingRestoreOPS();
+          return;
+        }
+        throw reason;
+      });
+    },
+    getTextContent({ stream, task, resources, stateManager = null, normalizeWhitespace = false, combineTextItems = false, sink, seenStyles = Object.create(null) }) {
+      resources = resources || _primitives.Dict.empty;
+      stateManager = stateManager || new StateManager(new TextState());
+      var WhitespaceRegexp = /\s/g;
+      var textContent = {
+        items: [],
+        styles: Object.create(null)
+      };
+      var textContentItem = {
+        initialized: false,
+        str: [],
+        width: 0,
+        height: 0,
+        vertical: false,
+        lastAdvanceWidth: 0,
+        lastAdvanceHeight: 0,
+        textAdvanceScale: 0,
+        spaceWidth: 0,
+        fakeSpaceMin: Infinity,
+        fakeMultiSpaceMin: Infinity,
+        fakeMultiSpaceMax: -0,
+        textRunBreakAllowed: false,
+        transform: null,
+        fontName: null
+      };
+      var SPACE_FACTOR = 0.3;
+      var MULTI_SPACE_FACTOR = 1.5;
+      var MULTI_SPACE_FACTOR_MAX = 4;
+      var self = this;
+      var xref = this.xref;
+      var xobjs = null;
+      var skipEmptyXObjs = Object.create(null);
+      var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
+      var textState;
+      function ensureTextContentItem() {
+        if (textContentItem.initialized) {
+          return textContentItem;
+        }
+        var font = textState.font;
+        if (!(font.loadedName in seenStyles)) {
+          seenStyles[font.loadedName] = true;
+          textContent.styles[font.loadedName] = {
+            fontFamily: font.fallbackName,
+            ascent: font.ascent,
+            descent: font.descent,
+            vertical: font.vertical
+          };
+        }
+        textContentItem.fontName = font.loadedName;
+        var tsm = [textState.fontSize * textState.textHScale, 0, 0, textState.fontSize, 0, textState.textRise];
+        if (font.isType3Font && textState.fontMatrix !== _util.FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
+          var glyphHeight = font.bbox[3] - font.bbox[1];
+          if (glyphHeight > 0) {
+            glyphHeight = glyphHeight * textState.fontMatrix[3];
+            tsm[3] *= glyphHeight;
+          }
+        }
+        var trm = _util.Util.transform(textState.ctm, _util.Util.transform(textState.textMatrix, tsm));
+        textContentItem.transform = trm;
+        if (!font.vertical) {
+          textContentItem.width = 0;
+          textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
+          textContentItem.vertical = false;
+        } else {
+          textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
+          textContentItem.height = 0;
+          textContentItem.vertical = true;
+        }
+        var a = textState.textLineMatrix[0];
+        var b = textState.textLineMatrix[1];
+        var scaleLineX = Math.sqrt(a * a + b * b);
+        a = textState.ctm[0];
+        b = textState.ctm[1];
+        var scaleCtmX = Math.sqrt(a * a + b * b);
+        textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
+        textContentItem.lastAdvanceWidth = 0;
+        textContentItem.lastAdvanceHeight = 0;
+        var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
+        if (spaceWidth) {
+          textContentItem.spaceWidth = spaceWidth;
+          textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
+          textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
+          textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
+          textContentItem.textRunBreakAllowed = !font.isMonospace;
+        } else {
+          textContentItem.spaceWidth = 0;
+          textContentItem.fakeSpaceMin = Infinity;
+          textContentItem.fakeMultiSpaceMin = Infinity;
+          textContentItem.fakeMultiSpaceMax = 0;
+          textContentItem.textRunBreakAllowed = false;
+        }
+        textContentItem.initialized = true;
+        return textContentItem;
+      }
+      function replaceWhitespace(str) {
+        var i = 0,
+            ii = str.length,
+            code;
+        while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
+          i++;
+        }
+        return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
+      }
+      function runBidiTransform(textChunk) {
+        var str = textChunk.str.join('');
+        var bidiResult = (0, _bidi.bidi)(str, -1, textChunk.vertical);
+        return {
+          str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
+          dir: bidiResult.dir,
+          width: textChunk.width,
+          height: textChunk.height,
+          transform: textChunk.transform,
+          fontName: textChunk.fontName
+        };
+      }
+      function handleSetFont(fontName, fontRef) {
+        return self.loadFont(fontName, fontRef, resources).then(function (translated) {
+          textState.font = translated.font;
+          textState.fontMatrix = translated.font.fontMatrix || _util.FONT_IDENTITY_MATRIX;
+        });
+      }
+      function buildTextContentItem(chars) {
+        var font = textState.font;
+        var textChunk = ensureTextContentItem();
+        var width = 0;
+        var height = 0;
+        var glyphs = font.charsToGlyphs(chars);
+        for (var i = 0; i < glyphs.length; i++) {
+          var glyph = glyphs[i];
+          var glyphWidth = null;
+          if (font.vertical && glyph.vmetric) {
+            glyphWidth = glyph.vmetric[0];
+          } else {
+            glyphWidth = glyph.width;
+          }
+          var glyphUnicode = glyph.unicode;
+          var NormalizedUnicodes = (0, _unicode.getNormalizedUnicodes)();
+          if (NormalizedUnicodes[glyphUnicode] !== undefined) {
+            glyphUnicode = NormalizedUnicodes[glyphUnicode];
+          }
+          glyphUnicode = (0, _unicode.reverseIfRtl)(glyphUnicode);
+          var charSpacing = textState.charSpacing;
+          if (glyph.isSpace) {
+            var wordSpacing = textState.wordSpacing;
+            charSpacing += wordSpacing;
+            if (wordSpacing > 0) {
+              addFakeSpaces(wordSpacing, textChunk.str);
+            }
+          }
+          var tx = 0;
+          var ty = 0;
+          if (!font.vertical) {
+            var w0 = glyphWidth * textState.fontMatrix[0];
+            tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
+            width += tx;
+          } else {
+            var w1 = glyphWidth * textState.fontMatrix[0];
+            ty = w1 * textState.fontSize + charSpacing;
+            height += ty;
+          }
+          textState.translateTextMatrix(tx, ty);
+          textChunk.str.push(glyphUnicode);
+        }
+        if (!font.vertical) {
+          textChunk.lastAdvanceWidth = width;
+          textChunk.width += width;
+        } else {
+          textChunk.lastAdvanceHeight = height;
+          textChunk.height += Math.abs(height);
+        }
+        return textChunk;
+      }
+      function addFakeSpaces(width, strBuf) {
+        if (width < textContentItem.fakeSpaceMin) {
+          return;
+        }
+        if (width < textContentItem.fakeMultiSpaceMin) {
+          strBuf.push(' ');
+          return;
+        }
+        var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
+        while (fakeSpaces-- > 0) {
+          strBuf.push(' ');
+        }
+      }
+      function flushTextContentItem() {
+        if (!textContentItem.initialized) {
+          return;
+        }
+        textContentItem.width *= textContentItem.textAdvanceScale;
+        textContentItem.height *= textContentItem.textAdvanceScale;
+        textContent.items.push(runBidiTransform(textContentItem));
+        textContentItem.initialized = false;
+        textContentItem.str.length = 0;
+      }
+      function enqueueChunk() {
+        let length = textContent.items.length;
+        if (length > 0) {
+          sink.enqueue(textContent, length);
+          textContent.items = [];
+          textContent.styles = Object.create(null);
+        }
+      }
+      var timeSlotManager = new TimeSlotManager();
+      return new Promise(function promiseBody(resolve, reject) {
+        let next = function (promise) {
+          enqueueChunk();
+          Promise.all([promise, sink.ready]).then(function () {
+            try {
+              promiseBody(resolve, reject);
+            } catch (ex) {
+              reject(ex);
+            }
+          }, reject);
+        };
+        task.ensureNotTerminated();
+        timeSlotManager.reset();
+        var stop,
+            operation = {},
+            args = [];
+        while (!(stop = timeSlotManager.check())) {
+          args.length = 0;
+          operation.args = args;
+          if (!preprocessor.read(operation)) {
+            break;
+          }
+          textState = stateManager.state;
+          var fn = operation.fn;
+          args = operation.args;
+          var advance, diff;
+          switch (fn | 0) {
+            case _util.OPS.setFont:
+              var fontNameArg = args[0].name,
+                  fontSizeArg = args[1];
+              if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
+                break;
+              }
+              flushTextContentItem();
+              textState.fontName = fontNameArg;
+              textState.fontSize = fontSizeArg;
+              next(handleSetFont(fontNameArg, null));
+              return;
+            case _util.OPS.setTextRise:
+              flushTextContentItem();
+              textState.textRise = args[0];
+              break;
+            case _util.OPS.setHScale:
+              flushTextContentItem();
+              textState.textHScale = args[0] / 100;
+              break;
+            case _util.OPS.setLeading:
+              flushTextContentItem();
+              textState.leading = args[0];
+              break;
+            case _util.OPS.moveText:
+              var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
+              advance = args[0] - args[1];
+              if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
+                textState.translateTextLineMatrix(args[0], args[1]);
+                textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
+                textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
+                diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
+                addFakeSpaces(diff, textContentItem.str);
+                break;
+              }
+              flushTextContentItem();
+              textState.translateTextLineMatrix(args[0], args[1]);
+              textState.textMatrix = textState.textLineMatrix.slice();
+              break;
+            case _util.OPS.setLeadingMoveText:
+              flushTextContentItem();
+              textState.leading = -args[1];
+              textState.translateTextLineMatrix(args[0], args[1]);
+              textState.textMatrix = textState.textLineMatrix.slice();
+              break;
+            case _util.OPS.nextLine:
+              flushTextContentItem();
+              textState.carriageReturn();
+              break;
+            case _util.OPS.setTextMatrix:
+              advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
+              if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
+                textState.translateTextLineMatrix(advance.width, advance.height);
+                textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
+                textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
+                diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
+                addFakeSpaces(diff, textContentItem.str);
+                break;
+              }
+              flushTextContentItem();
+              textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
+              textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
+              break;
+            case _util.OPS.setCharSpacing:
+              textState.charSpacing = args[0];
+              break;
+            case _util.OPS.setWordSpacing:
+              textState.wordSpacing = args[0];
+              break;
+            case _util.OPS.beginText:
+              flushTextContentItem();
+              textState.textMatrix = _util.IDENTITY_MATRIX.slice();
+              textState.textLineMatrix = _util.IDENTITY_MATRIX.slice();
+              break;
+            case _util.OPS.showSpacedText:
+              var items = args[0];
+              var offset;
+              for (var j = 0, jj = items.length; j < jj; j++) {
+                if (typeof items[j] === 'string') {
+                  buildTextContentItem(items[j]);
+                } else if ((0, _util.isNum)(items[j])) {
+                  ensureTextContentItem();
+                  advance = items[j] * textState.fontSize / 1000;
+                  var breakTextRun = false;
+                  if (textState.font.vertical) {
+                    offset = advance;
+                    textState.translateTextMatrix(0, offset);
+                    breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
+                    if (!breakTextRun) {
+                      textContentItem.height += offset;
+                    }
+                  } else {
+                    advance = -advance;
+                    offset = advance * textState.textHScale;
+                    textState.translateTextMatrix(offset, 0);
+                    breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
+                    if (!breakTextRun) {
+                      textContentItem.width += offset;
+                    }
+                  }
+                  if (breakTextRun) {
+                    flushTextContentItem();
+                  } else if (advance > 0) {
+                    addFakeSpaces(advance, textContentItem.str);
+                  }
+                }
+              }
+              break;
+            case _util.OPS.showText:
+              buildTextContentItem(args[0]);
+              break;
+            case _util.OPS.nextLineShowText:
+              flushTextContentItem();
+              textState.carriageReturn();
+              buildTextContentItem(args[0]);
+              break;
+            case _util.OPS.nextLineSetSpacingShowText:
+              flushTextContentItem();
+              textState.wordSpacing = args[0];
+              textState.charSpacing = args[1];
+              textState.carriageReturn();
+              buildTextContentItem(args[2]);
+              break;
+            case _util.OPS.paintXObject:
+              flushTextContentItem();
+              if (!xobjs) {
+                xobjs = resources.get('XObject') || _primitives.Dict.empty;
+              }
+              var name = args[0].name;
+              if (name && skipEmptyXObjs[name] !== undefined) {
+                break;
+              }
+              next(new Promise(function (resolveXObject, rejectXObject) {
+                if (!name) {
+                  throw new _util.FormatError('XObject must be referred to by name.');
+                }
+                let xobj = xobjs.get(name);
+                if (!xobj) {
+                  resolveXObject();
+                  return;
+                }
+                if (!(0, _primitives.isStream)(xobj)) {
+                  throw new _util.FormatError('XObject should be a stream');
+                }
+                let type = xobj.dict.get('Subtype');
+                if (!(0, _primitives.isName)(type)) {
+                  throw new _util.FormatError('XObject should have a Name subtype');
+                }
+                if (type.name !== 'Form') {
+                  skipEmptyXObjs[name] = true;
+                  resolveXObject();
+                  return;
+                }
+                let currentState = stateManager.state.clone();
+                let xObjStateManager = new StateManager(currentState);
+                let matrix = xobj.dict.getArray('Matrix');
+                if (Array.isArray(matrix) && matrix.length === 6) {
+                  xObjStateManager.transform(matrix);
+                }
+                enqueueChunk();
+                let sinkWrapper = {
+                  enqueueInvoked: false,
+                  enqueue(chunk, size) {
+                    this.enqueueInvoked = true;
+                    sink.enqueue(chunk, size);
+                  },
+                  get desiredSize() {
+                    return sink.desiredSize;
+                  },
+                  get ready() {
+                    return sink.ready;
+                  }
+                };
+                self.getTextContent({
+                  stream: xobj,
+                  task,
+                  resources: xobj.dict.get('Resources') || resources,
+                  stateManager: xObjStateManager,
+                  normalizeWhitespace,
+                  combineTextItems,
+                  sink: sinkWrapper,
+                  seenStyles
+                }).then(function () {
+                  if (!sinkWrapper.enqueueInvoked) {
+                    skipEmptyXObjs[name] = true;
+                  }
+                  resolveXObject();
+                }, rejectXObject);
+              }).catch(function (reason) {
+                if (reason instanceof _util.AbortException) {
+                  return;
+                }
+                if (self.options.ignoreErrors) {
+                  (0, _util.warn)(`getTextContent - ignoring XObject: "${reason}".`);
+                  return;
+                }
+                throw reason;
+              }));
+              return;
+            case _util.OPS.setGState:
+              flushTextContentItem();
+              var dictName = args[0];
+              var extGState = resources.get('ExtGState');
+              if (!(0, _primitives.isDict)(extGState) || !(0, _primitives.isName)(dictName)) {
+                break;
+              }
+              var gState = extGState.get(dictName.name);
+              if (!(0, _primitives.isDict)(gState)) {
+                break;
+              }
+              var gStateFont = gState.get('Font');
+              if (gStateFont) {
+                textState.fontName = null;
+                textState.fontSize = gStateFont[1];
+                next(handleSetFont(null, gStateFont[0]));
+                return;
+              }
+              break;
+          }
+          if (textContent.items.length >= sink.desiredSize) {
+            stop = true;
+            break;
+          }
+        }
+        if (stop) {
+          next(deferred);
+          return;
+        }
+        flushTextContentItem();
+        enqueueChunk();
+        resolve();
+      }).catch(reason => {
+        if (reason instanceof _util.AbortException) {
+          return;
+        }
+        if (this.options.ignoreErrors) {
+          (0, _util.warn)('getTextContent - ignoring errors during task: ' + task.name);
+          flushTextContentItem();
+          enqueueChunk();
+          return;
+        }
+        throw reason;
+      });
+    },
+    extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, properties) {
+      var xref = this.xref;
+      var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
+      var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
+      if (properties.composite) {
+        var cidSystemInfo = dict.get('CIDSystemInfo');
+        if ((0, _primitives.isDict)(cidSystemInfo)) {
+          properties.cidSystemInfo = {
+            registry: cidSystemInfo.get('Registry'),
+            ordering: cidSystemInfo.get('Ordering'),
+            supplement: cidSystemInfo.get('Supplement')
+          };
+        }
+        var cidToGidMap = dict.get('CIDToGIDMap');
+        if ((0, _primitives.isStream)(cidToGidMap)) {
+          properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
+        }
+      }
+      var differences = [];
+      var baseEncodingName = null;
+      var encoding;
+      if (dict.has('Encoding')) {
+        encoding = dict.get('Encoding');
+        if ((0, _primitives.isDict)(encoding)) {
+          baseEncodingName = encoding.get('BaseEncoding');
+          baseEncodingName = (0, _primitives.isName)(baseEncodingName) ? baseEncodingName.name : null;
+          if (encoding.has('Differences')) {
+            var diffEncoding = encoding.get('Differences');
+            var index = 0;
+            for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
+              var data = xref.fetchIfRef(diffEncoding[j]);
+              if ((0, _util.isNum)(data)) {
+                index = data;
+              } else if ((0, _primitives.isName)(data)) {
+                differences[index++] = data.name;
+              } else {
+                throw new _util.FormatError(`Invalid entry in 'Differences' array: ${data}`);
+              }
+            }
+          }
+        } else if ((0, _primitives.isName)(encoding)) {
+          baseEncodingName = encoding.name;
+        } else {
+          throw new _util.FormatError('Encoding is not a Name nor a Dict');
+        }
+        if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
+          baseEncodingName = null;
+        }
+      }
+      if (baseEncodingName) {
+        properties.defaultEncoding = (0, _encodings.getEncoding)(baseEncodingName).slice();
+      } else {
+        var isSymbolicFont = !!(properties.flags & _fonts.FontFlags.Symbolic);
+        var isNonsymbolicFont = !!(properties.flags & _fonts.FontFlags.Nonsymbolic);
+        encoding = _encodings.StandardEncoding;
+        if (properties.type === 'TrueType' && !isNonsymbolicFont) {
+          encoding = _encodings.WinAnsiEncoding;
+        }
+        if (isSymbolicFont) {
+          encoding = _encodings.MacRomanEncoding;
+          if (!properties.file) {
+            if (/Symbol/i.test(properties.name)) {
+              encoding = _encodings.SymbolSetEncoding;
+            } else if (/Dingbats/i.test(properties.name)) {
+              encoding = _encodings.ZapfDingbatsEncoding;
+            }
+          }
+        }
+        properties.defaultEncoding = encoding;
+      }
+      properties.differences = differences;
+      properties.baseEncodingName = baseEncodingName;
+      properties.hasEncoding = !!baseEncodingName || differences.length > 0;
+      properties.dict = dict;
+      return toUnicodePromise.then(toUnicode => {
+        properties.toUnicode = toUnicode;
+        return this.buildToUnicode(properties);
+      }).then(function (toUnicode) {
+        properties.toUnicode = toUnicode;
+        return properties;
+      });
+    },
+    buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
+      properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
+      if (properties.hasIncludedToUnicodeMap) {
+        return Promise.resolve(properties.toUnicode);
+      }
+      var toUnicode, charcode, glyphName;
+      if (!properties.composite) {
+        toUnicode = [];
+        var encoding = properties.defaultEncoding.slice();
+        var baseEncodingName = properties.baseEncodingName;
+        var differences = properties.differences;
+        for (charcode in differences) {
+          glyphName = differences[charcode];
+          if (glyphName === '.notdef') {
+            continue;
+          }
+          encoding[charcode] = glyphName;
+        }
+        var glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
+        for (charcode in encoding) {
+          glyphName = encoding[charcode];
+          if (glyphName === '') {
+            continue;
+          } else if (glyphsUnicodeMap[glyphName] === undefined) {
+            var code = 0;
+            switch (glyphName[0]) {
+              case 'G':
+                if (glyphName.length === 3) {
+                  code = parseInt(glyphName.substr(1), 16);
+                }
+                break;
+              case 'g':
+                if (glyphName.length === 5) {
+                  code = parseInt(glyphName.substr(1), 16);
+                }
+                break;
+              case 'C':
+              case 'c':
+                if (glyphName.length >= 3) {
+                  code = +glyphName.substr(1);
+                }
+                break;
+              default:
+                var unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
+                if (unicode !== -1) {
+                  code = unicode;
+                }
+            }
+            if (code) {
+              if (baseEncodingName && code === +charcode) {
+                var baseEncoding = (0, _encodings.getEncoding)(baseEncodingName);
+                if (baseEncoding && (glyphName = baseEncoding[charcode])) {
+                  toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
+                  continue;
+                }
+              }
+              toUnicode[charcode] = String.fromCharCode(code);
+            }
+            continue;
+          }
+          toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
+        }
+        return Promise.resolve(new _fonts.ToUnicodeMap(toUnicode));
+      }
+      if (properties.composite && (properties.cMap.builtInCMap && !(properties.cMap instanceof _cmap.IdentityCMap) || properties.cidSystemInfo.registry === 'Adobe' && (properties.cidSystemInfo.ordering === 'GB1' || properties.cidSystemInfo.ordering === 'CNS1' || properties.cidSystemInfo.ordering === 'Japan1' || properties.cidSystemInfo.ordering === 'Korea1'))) {
+        var registry = properties.cidSystemInfo.registry;
+        var ordering = properties.cidSystemInfo.ordering;
+        var ucs2CMapName = _primitives.Name.get(registry + '-' + ordering + '-UCS2');
+        return _cmap.CMapFactory.create({
+          encoding: ucs2CMapName,
+          fetchBuiltInCMap: this.fetchBuiltInCMap,
+          useCMap: null
+        }).then(function (ucs2CMap) {
+          var cMap = properties.cMap;
+          toUnicode = [];
+          cMap.forEach(function (charcode, cid) {
+            if (cid > 0xffff) {
+              throw new _util.FormatError('Max size of CID is 65,535');
+            }
+            var ucs2 = ucs2CMap.lookup(cid);
+            if (ucs2) {
+              toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
+            }
+          });
+          return new _fonts.ToUnicodeMap(toUnicode);
+        });
+      }
+      return Promise.resolve(new _fonts.IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
+    },
+    readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
+      var cmapObj = toUnicode;
+      if ((0, _primitives.isName)(cmapObj)) {
+        return _cmap.CMapFactory.create({
+          encoding: cmapObj,
+          fetchBuiltInCMap: this.fetchBuiltInCMap,
+          useCMap: null
+        }).then(function (cmap) {
+          if (cmap instanceof _cmap.IdentityCMap) {
+            return new _fonts.IdentityToUnicodeMap(0, 0xFFFF);
+          }
+          return new _fonts.ToUnicodeMap(cmap.getMap());
+        });
+      } else if ((0, _primitives.isStream)(cmapObj)) {
+        return _cmap.CMapFactory.create({
+          encoding: cmapObj,
+          fetchBuiltInCMap: this.fetchBuiltInCMap,
+          useCMap: null
+        }).then(function (cmap) {
+          if (cmap instanceof _cmap.IdentityCMap) {
+            return new _fonts.IdentityToUnicodeMap(0, 0xFFFF);
+          }
+          var map = new Array(cmap.length);
+          cmap.forEach(function (charCode, token) {
+            var str = [];
+            for (var k = 0; k < token.length; k += 2) {
+              var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
+              if ((w1 & 0xF800) !== 0xD800) {
+                str.push(w1);
+                continue;
+              }
+              k += 2;
+              var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
+              str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
+            }
+            map[charCode] = String.fromCharCode.apply(String, str);
+          });
+          return new _fonts.ToUnicodeMap(map);
+        });
+      }
+      return Promise.resolve(null);
+    },
+    readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
+      var glyphsData = cidToGidStream.getBytes();
+      var result = [];
+      for (var j = 0, jj = glyphsData.length; j < jj; j++) {
+        var glyphID = glyphsData[j++] << 8 | glyphsData[j];
+        if (glyphID === 0) {
+          continue;
+        }
+        var code = j >> 1;
+        result[code] = glyphID;
+      }
+      return result;
+    },
+    extractWidths: function PartialEvaluator_extractWidths(dict, descriptor, properties) {
+      var xref = this.xref;
+      var glyphsWidths = [];
+      var defaultWidth = 0;
+      var glyphsVMetrics = [];
+      var defaultVMetrics;
+      var i, ii, j, jj, start, code, widths;
+      if (properties.composite) {
+        defaultWidth = dict.has('DW') ? dict.get('DW') : 1000;
+        widths = dict.get('W');
+        if (widths) {
+          for (i = 0, ii = widths.length; i < ii; i++) {
+            start = xref.fetchIfRef(widths[i++]);
+            code = xref.fetchIfRef(widths[i]);
+            if (Array.isArray(code)) {
+              for (j = 0, jj = code.length; j < jj; j++) {
+                glyphsWidths[start++] = xref.fetchIfRef(code[j]);
+              }
+            } else {
+              var width = xref.fetchIfRef(widths[++i]);
+              for (j = start; j <= code; j++) {
+                glyphsWidths[j] = width;
+              }
+            }
+          }
+        }
+        if (properties.vertical) {
+          var vmetrics = dict.getArray('DW2') || [880, -1000];
+          defaultVMetrics = [vmetrics[1], defaultWidth * 0.5, vmetrics[0]];
+          vmetrics = dict.get('W2');
+          if (vmetrics) {
+            for (i = 0, ii = vmetrics.length; i < ii; i++) {
+              start = xref.fetchIfRef(vmetrics[i++]);
+              code = xref.fetchIfRef(vmetrics[i]);
+              if (Array.isArray(code)) {
+                for (j = 0, jj = code.length; j < jj; j++) {
+                  glyphsVMetrics[start++] = [xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j])];
+                }
+              } else {
+                var vmetric = [xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i])];
+                for (j = start; j <= code; j++) {
+                  glyphsVMetrics[j] = vmetric;
+                }
+              }
+            }
+          }
+        }
+      } else {
+        var firstChar = properties.firstChar;
+        widths = dict.get('Widths');
+        if (widths) {
+          j = firstChar;
+          for (i = 0, ii = widths.length; i < ii; i++) {
+            glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
+          }
+          defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
+        } else {
+          var baseFontName = dict.get('BaseFont');
+          if ((0, _primitives.isName)(baseFontName)) {
+            var metrics = this.getBaseFontMetrics(baseFontName.name);
+            glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
+            defaultWidth = metrics.defaultWidth;
+          }
+        }
+      }
+      var isMonospace = true;
+      var firstWidth = defaultWidth;
+      for (var glyph in glyphsWidths) {
+        var glyphWidth = glyphsWidths[glyph];
+        if (!glyphWidth) {
+          continue;
+        }
+        if (!firstWidth) {
+          firstWidth = glyphWidth;
+          continue;
+        }
+        if (firstWidth !== glyphWidth) {
+          isMonospace = false;
+          break;
+        }
+      }
+      if (isMonospace) {
+        properties.flags |= _fonts.FontFlags.FixedPitch;
+      }
+      properties.defaultWidth = defaultWidth;
+      properties.widths = glyphsWidths;
+      properties.defaultVMetrics = defaultVMetrics;
+      properties.vmetrics = glyphsVMetrics;
+    },
+    isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
+      var fontNameWoStyle = baseFontName.split('-')[0];
+      return fontNameWoStyle in (0, _standard_fonts.getSerifFonts)() || fontNameWoStyle.search(/serif/gi) !== -1;
+    },
+    getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
+      var defaultWidth = 0;
+      var widths = [];
+      var monospace = false;
+      var stdFontMap = (0, _standard_fonts.getStdFontMap)();
+      var lookupName = stdFontMap[name] || name;
+      var Metrics = (0, _metrics.getMetrics)();
+      if (!(lookupName in Metrics)) {
+        if (this.isSerifFont(name)) {
+          lookupName = 'Times-Roman';
+        } else {
+          lookupName = 'Helvetica';
+        }
+      }
+      var glyphWidths = Metrics[lookupName];
+      if ((0, _util.isNum)(glyphWidths)) {
+        defaultWidth = glyphWidths;
+        monospace = true;
+      } else {
+        widths = glyphWidths();
+      }
+      return {
+        defaultWidth,
+        monospace,
+        widths
+      };
+    },
+    buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
+      var widths = Object.create(null);
+      var differences = properties.differences;
+      var encoding = properties.defaultEncoding;
+      for (var charCode = 0; charCode < 256; charCode++) {
+        if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
+          widths[charCode] = widthsByGlyphName[differences[charCode]];
+          continue;
+        }
+        if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
+          widths[charCode] = widthsByGlyphName[encoding[charCode]];
+          continue;
+        }
+      }
+      return widths;
+    },
+    preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict) {
+      var baseDict = dict;
+      var type = dict.get('Subtype');
+      if (!(0, _primitives.isName)(type)) {
+        throw new _util.FormatError('invalid font Subtype');
+      }
+      var composite = false;
+      var uint8array;
+      if (type.name === 'Type0') {
+        var df = dict.get('DescendantFonts');
+        if (!df) {
+          throw new _util.FormatError('Descendant fonts are not specified');
+        }
+        dict = Array.isArray(df) ? this.xref.fetchIfRef(df[0]) : df;
+        type = dict.get('Subtype');
+        if (!(0, _primitives.isName)(type)) {
+          throw new _util.FormatError('invalid font Subtype');
+        }
+        composite = true;
+      }
+      var descriptor = dict.get('FontDescriptor');
+      if (descriptor) {
+        var hash = new _murmurhash.MurmurHash3_64();
+        var encoding = baseDict.getRaw('Encoding');
+        if ((0, _primitives.isName)(encoding)) {
+          hash.update(encoding.name);
+        } else if ((0, _primitives.isRef)(encoding)) {
+          hash.update(encoding.toString());
+        } else if ((0, _primitives.isDict)(encoding)) {
+          var keys = encoding.getKeys();
+          for (var i = 0, ii = keys.length; i < ii; i++) {
+            var entry = encoding.getRaw(keys[i]);
+            if ((0, _primitives.isName)(entry)) {
+              hash.update(entry.name);
+            } else if ((0, _primitives.isRef)(entry)) {
+              hash.update(entry.toString());
+            } else if (Array.isArray(entry)) {
+              var diffLength = entry.length,
+                  diffBuf = new Array(diffLength);
+              for (var j = 0; j < diffLength; j++) {
+                var diffEntry = entry[j];
+                if ((0, _primitives.isName)(diffEntry)) {
+                  diffBuf[j] = diffEntry.name;
+                } else if ((0, _util.isNum)(diffEntry) || (0, _primitives.isRef)(diffEntry)) {
+                  diffBuf[j] = diffEntry.toString();
+                }
+              }
+              hash.update(diffBuf.join());
+            }
+          }
+        }
+        var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
+        if ((0, _primitives.isStream)(toUnicode)) {
+          var stream = toUnicode.str || toUnicode;
+          uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
+          hash.update(uint8array);
+        } else if ((0, _primitives.isName)(toUnicode)) {
+          hash.update(toUnicode.name);
+        }
+        var widths = dict.get('Widths') || baseDict.get('Widths');
+        if (widths) {
+          uint8array = new Uint8Array(new Uint32Array(widths).buffer);
+          hash.update(uint8array);
+        }
+      }
+      return {
+        descriptor,
+        dict,
+        baseDict,
+        composite,
+        type: type.name,
+        hash: hash ? hash.hexdigest() : ''
+      };
+    },
+    translateFont: function PartialEvaluator_translateFont(preEvaluatedFont) {
+      var baseDict = preEvaluatedFont.baseDict;
+      var dict = preEvaluatedFont.dict;
+      var composite = preEvaluatedFont.composite;
+      var descriptor = preEvaluatedFont.descriptor;
+      var type = preEvaluatedFont.type;
+      var maxCharIndex = composite ? 0xFFFF : 0xFF;
+      var properties;
+      if (!descriptor) {
+        if (type === 'Type3') {
+          descriptor = new _primitives.Dict(null);
+          descriptor.set('FontName', _primitives.Name.get(type));
+          descriptor.set('FontBBox', dict.getArray('FontBBox'));
+        } else {
+          var baseFontName = dict.get('BaseFont');
+          if (!(0, _primitives.isName)(baseFontName)) {
+            throw new _util.FormatError('Base font is not specified');
+          }
+          baseFontName = baseFontName.name.replace(/[,_]/g, '-');
+          var metrics = this.getBaseFontMetrics(baseFontName);
+          var fontNameWoStyle = baseFontName.split('-')[0];
+          var flags = (this.isSerifFont(fontNameWoStyle) ? _fonts.FontFlags.Serif : 0) | (metrics.monospace ? _fonts.FontFlags.FixedPitch : 0) | ((0, _standard_fonts.getSymbolsFonts)()[fontNameWoStyle] ? _fonts.FontFlags.Symbolic : _fonts.FontFlags.Nonsymbolic);
+          properties = {
+            type,
+            name: baseFontName,
+            widths: metrics.widths,
+            defaultWidth: metrics.defaultWidth,
+            flags,
+            firstChar: 0,
+            lastChar: maxCharIndex
+          };
+          return this.extractDataStructures(dict, dict, properties).then(properties => {
+            properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
+            return new _fonts.Font(baseFontName, null, properties);
+          });
+        }
+      }
+      var firstChar = dict.get('FirstChar') || 0;
+      var lastChar = dict.get('LastChar') || maxCharIndex;
+      var fontName = descriptor.get('FontName');
+      var baseFont = dict.get('BaseFont');
+      if ((0, _util.isString)(fontName)) {
+        fontName = _primitives.Name.get(fontName);
+      }
+      if ((0, _util.isString)(baseFont)) {
+        baseFont = _primitives.Name.get(baseFont);
+      }
+      if (type !== 'Type3') {
+        var fontNameStr = fontName && fontName.name;
+        var baseFontStr = baseFont && baseFont.name;
+        if (fontNameStr !== baseFontStr) {
+          (0, _util.info)('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
+          if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
+            fontName = baseFont;
+          }
+        }
+      }
+      fontName = fontName || baseFont;
+      if (!(0, _primitives.isName)(fontName)) {
+        throw new _util.FormatError('invalid font name');
+      }
+      var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
+      if (fontFile) {
+        if (fontFile.dict) {
+          var subtype = fontFile.dict.get('Subtype');
+          if (subtype) {
+            subtype = subtype.name;
+          }
+          var length1 = fontFile.dict.get('Length1');
+          var length2 = fontFile.dict.get('Length2');
+          var length3 = fontFile.dict.get('Length3');
+        }
+      }
+      properties = {
+        type,
+        name: fontName.name,
+        subtype,
+        file: fontFile,
+        length1,
+        length2,
+        length3,
+        loadedName: baseDict.loadedName,
+        composite,
+        wideChars: composite,
+        fixedPitch: false,
+        fontMatrix: dict.getArray('FontMatrix') || _util.FONT_IDENTITY_MATRIX,
+        firstChar: firstChar || 0,
+        lastChar: lastChar || maxCharIndex,
+        bbox: descriptor.getArray('FontBBox'),
+        ascent: descriptor.get('Ascent'),
+        descent: descriptor.get('Descent'),
+        xHeight: descriptor.get('XHeight'),
+        capHeight: descriptor.get('CapHeight'),
+        flags: descriptor.get('Flags'),
+        italicAngle: descriptor.get('ItalicAngle'),
+        isType3Font: false
+      };
+      var cMapPromise;
+      if (composite) {
+        var cidEncoding = baseDict.get('Encoding');
+        if ((0, _primitives.isName)(cidEncoding)) {
+          properties.cidEncoding = cidEncoding.name;
+        }
+        cMapPromise = _cmap.CMapFactory.create({
+          encoding: cidEncoding,
+          fetchBuiltInCMap: this.fetchBuiltInCMap,
+          useCMap: null
+        }).then(function (cMap) {
+          properties.cMap = cMap;
+          properties.vertical = properties.cMap.vertical;
+        });
+      } else {
+        cMapPromise = Promise.resolve(undefined);
+      }
+      return cMapPromise.then(() => {
+        return this.extractDataStructures(dict, baseDict, properties);
+      }).then(properties => {
+        this.extractWidths(dict, descriptor, properties);
+        if (type === 'Type3') {
+          properties.isType3Font = true;
+        }
+        return new _fonts.Font(fontName.name, fontFile, properties);
+      });
+    }
+  };
+  return PartialEvaluator;
+}();
+var TranslatedFont = function TranslatedFontClosure() {
+  function TranslatedFont(loadedName, font, dict) {
+    this.loadedName = loadedName;
+    this.font = font;
+    this.dict = dict;
+    this.type3Loaded = null;
+    this.sent = false;
+  }
+  TranslatedFont.prototype = {
+    send(handler) {
+      if (this.sent) {
+        return;
+      }
+      var fontData = this.font.exportData();
+      handler.send('commonobj', [this.loadedName, 'Font', fontData]);
+      this.sent = true;
+    },
+    loadType3Data(evaluator, resources, parentOperatorList, task) {
+      if (!this.font.isType3Font) {
+        throw new Error('Must be a Type3 font.');
+      }
+      if (this.type3Loaded) {
+        return this.type3Loaded;
+      }
+      var type3Options = Object.create(evaluator.options);
+      type3Options.ignoreErrors = false;
+      var type3Evaluator = evaluator.clone(type3Options);
+      var translatedFont = this.font;
+      var loadCharProcsPromise = Promise.resolve();
+      var charProcs = this.dict.get('CharProcs');
+      var fontResources = this.dict.get('Resources') || resources;
+      var charProcKeys = charProcs.getKeys();
+      var charProcOperatorList = Object.create(null);
+      for (var i = 0, n = charProcKeys.length; i < n; ++i) {
+        let key = charProcKeys[i];
+        loadCharProcsPromise = loadCharProcsPromise.then(function () {
+          var glyphStream = charProcs.get(key);
+          var operatorList = new _operator_list.OperatorList();
+          return type3Evaluator.getOperatorList({
+            stream: glyphStream,
+            task,
+            resources: fontResources,
+            operatorList
+          }).then(function () {
+            charProcOperatorList[key] = operatorList.getIR();
+            parentOperatorList.addDependencies(operatorList.dependencies);
+          }).catch(function (reason) {
+            (0, _util.warn)(`Type3 font resource "${key}" is not available.`);
+            var operatorList = new _operator_list.OperatorList();
+            charProcOperatorList[key] = operatorList.getIR();
+          });
+        });
+      }
+      this.type3Loaded = loadCharProcsPromise.then(function () {
+        translatedFont.charProcOperatorList = charProcOperatorList;
+      });
+      return this.type3Loaded;
+    }
+  };
+  return TranslatedFont;
+}();
+var StateManager = function StateManagerClosure() {
+  function StateManager(initialState) {
+    this.state = initialState;
+    this.stateStack = [];
+  }
+  StateManager.prototype = {
+    save() {
+      var old = this.state;
+      this.stateStack.push(this.state);
+      this.state = old.clone();
+    },
+    restore() {
+      var prev = this.stateStack.pop();
+      if (prev) {
+        this.state = prev;
+      }
+    },
+    transform(args) {
+      this.state.ctm = _util.Util.transform(this.state.ctm, args);
+    }
+  };
+  return StateManager;
+}();
+var TextState = function TextStateClosure() {
+  function TextState() {
+    this.ctm = new Float32Array(_util.IDENTITY_MATRIX);
+    this.fontName = null;
+    this.fontSize = 0;
+    this.font = null;
+    this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
+    this.textMatrix = _util.IDENTITY_MATRIX.slice();
+    this.textLineMatrix = _util.IDENTITY_MATRIX.slice();
+    this.charSpacing = 0;
+    this.wordSpacing = 0;
+    this.leading = 0;
+    this.textHScale = 1;
+    this.textRise = 0;
+  }
+  TextState.prototype = {
+    setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
+      var m = this.textMatrix;
+      m[0] = a;
+      m[1] = b;
+      m[2] = c;
+      m[3] = d;
+      m[4] = e;
+      m[5] = f;
+    },
+    setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
+      var m = this.textLineMatrix;
+      m[0] = a;
+      m[1] = b;
+      m[2] = c;
+      m[3] = d;
+      m[4] = e;
+      m[5] = f;
+    },
+    translateTextMatrix: function TextState_translateTextMatrix(x, y) {
+      var m = this.textMatrix;
+      m[4] = m[0] * x + m[2] * y + m[4];
+      m[5] = m[1] * x + m[3] * y + m[5];
+    },
+    translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
+      var m = this.textLineMatrix;
+      m[4] = m[0] * x + m[2] * y + m[4];
+      m[5] = m[1] * x + m[3] * y + m[5];
+    },
+    calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
+      var font = this.font;
+      if (!font) {
+        return null;
+      }
+      var m = this.textLineMatrix;
+      if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
+        return null;
+      }
+      var txDiff = e - m[4],
+          tyDiff = f - m[5];
+      if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
+        return null;
+      }
+      var tx,
+          ty,
+          denominator = a * d - b * c;
+      if (font.vertical) {
+        tx = -tyDiff * c / denominator;
+        ty = tyDiff * a / denominator;
+      } else {
+        tx = txDiff * d / denominator;
+        ty = -txDiff * b / denominator;
+      }
+      return {
+        width: tx,
+        height: ty,
+        value: font.vertical ? ty : tx
+      };
+    },
+    calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
+      var tsm = [this.fontSize * this.textHScale, 0, 0, this.fontSize, 0, this.textRise];
+      return _util.Util.transform(ctm, _util.Util.transform(this.textMatrix, tsm));
+    },
+    carriageReturn: function TextState_carriageReturn() {
+      this.translateTextLineMatrix(0, -this.leading);
+      this.textMatrix = this.textLineMatrix.slice();
+    },
+    clone: function TextState_clone() {
+      var clone = Object.create(this);
+      clone.textMatrix = this.textMatrix.slice();
+      clone.textLineMatrix = this.textLineMatrix.slice();
+      clone.fontMatrix = this.fontMatrix.slice();
+      return clone;
+    }
+  };
+  return TextState;
+}();
+var EvalState = function EvalStateClosure() {
+  function EvalState() {
+    this.ctm = new Float32Array(_util.IDENTITY_MATRIX);
+    this.font = null;
+    this.textRenderingMode = _util.TextRenderingMode.FILL;
+    this.fillColorSpace = _colorspace.ColorSpace.singletons.gray;
+    this.strokeColorSpace = _colorspace.ColorSpace.singletons.gray;
+  }
+  EvalState.prototype = {
+    clone: function CanvasExtraState_clone() {
+      return Object.create(this);
+    }
+  };
+  return EvalState;
+}();
+var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
+  var getOPMap = (0, _util.getLookupTableFactory)(function (t) {
+    t['w'] = {
+      id: _util.OPS.setLineWidth,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['J'] = {
+      id: _util.OPS.setLineCap,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['j'] = {
+      id: _util.OPS.setLineJoin,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['M'] = {
+      id: _util.OPS.setMiterLimit,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['d'] = {
+      id: _util.OPS.setDash,
+      numArgs: 2,
+      variableArgs: false
+    };
+    t['ri'] = {
+      id: _util.OPS.setRenderingIntent,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['i'] = {
+      id: _util.OPS.setFlatness,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['gs'] = {
+      id: _util.OPS.setGState,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['q'] = {
+      id: _util.OPS.save,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['Q'] = {
+      id: _util.OPS.restore,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['cm'] = {
+      id: _util.OPS.transform,
+      numArgs: 6,
+      variableArgs: false
+    };
+    t['m'] = {
+      id: _util.OPS.moveTo,
+      numArgs: 2,
+      variableArgs: false
+    };
+    t['l'] = {
+      id: _util.OPS.lineTo,
+      numArgs: 2,
+      variableArgs: false
+    };
+    t['c'] = {
+      id: _util.OPS.curveTo,
+      numArgs: 6,
+      variableArgs: false
+    };
+    t['v'] = {
+      id: _util.OPS.curveTo2,
+      numArgs: 4,
+      variableArgs: false
+    };
+    t['y'] = {
+      id: _util.OPS.curveTo3,
+      numArgs: 4,
+      variableArgs: false
+    };
+    t['h'] = {
+      id: _util.OPS.closePath,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['re'] = {
+      id: _util.OPS.rectangle,
+      numArgs: 4,
+      variableArgs: false
+    };
+    t['S'] = {
+      id: _util.OPS.stroke,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['s'] = {
+      id: _util.OPS.closeStroke,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['f'] = {
+      id: _util.OPS.fill,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['F'] = {
+      id: _util.OPS.fill,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['f*'] = {
+      id: _util.OPS.eoFill,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['B'] = {
+      id: _util.OPS.fillStroke,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['B*'] = {
+      id: _util.OPS.eoFillStroke,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['b'] = {
+      id: _util.OPS.closeFillStroke,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['b*'] = {
+      id: _util.OPS.closeEOFillStroke,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['n'] = {
+      id: _util.OPS.endPath,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['W'] = {
+      id: _util.OPS.clip,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['W*'] = {
+      id: _util.OPS.eoClip,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['BT'] = {
+      id: _util.OPS.beginText,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['ET'] = {
+      id: _util.OPS.endText,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['Tc'] = {
+      id: _util.OPS.setCharSpacing,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['Tw'] = {
+      id: _util.OPS.setWordSpacing,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['Tz'] = {
+      id: _util.OPS.setHScale,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['TL'] = {
+      id: _util.OPS.setLeading,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['Tf'] = {
+      id: _util.OPS.setFont,
+      numArgs: 2,
+      variableArgs: false
+    };
+    t['Tr'] = {
+      id: _util.OPS.setTextRenderingMode,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['Ts'] = {
+      id: _util.OPS.setTextRise,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['Td'] = {
+      id: _util.OPS.moveText,
+      numArgs: 2,
+      variableArgs: false
+    };
+    t['TD'] = {
+      id: _util.OPS.setLeadingMoveText,
+      numArgs: 2,
+      variableArgs: false
+    };
+    t['Tm'] = {
+      id: _util.OPS.setTextMatrix,
+      numArgs: 6,
+      variableArgs: false
+    };
+    t['T*'] = {
+      id: _util.OPS.nextLine,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['Tj'] = {
+      id: _util.OPS.showText,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['TJ'] = {
+      id: _util.OPS.showSpacedText,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['\''] = {
+      id: _util.OPS.nextLineShowText,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['"'] = {
+      id: _util.OPS.nextLineSetSpacingShowText,
+      numArgs: 3,
+      variableArgs: false
+    };
+    t['d0'] = {
+      id: _util.OPS.setCharWidth,
+      numArgs: 2,
+      variableArgs: false
+    };
+    t['d1'] = {
+      id: _util.OPS.setCharWidthAndBounds,
+      numArgs: 6,
+      variableArgs: false
+    };
+    t['CS'] = {
+      id: _util.OPS.setStrokeColorSpace,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['cs'] = {
+      id: _util.OPS.setFillColorSpace,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['SC'] = {
+      id: _util.OPS.setStrokeColor,
+      numArgs: 4,
+      variableArgs: true
+    };
+    t['SCN'] = {
+      id: _util.OPS.setStrokeColorN,
+      numArgs: 33,
+      variableArgs: true
+    };
+    t['sc'] = {
+      id: _util.OPS.setFillColor,
+      numArgs: 4,
+      variableArgs: true
+    };
+    t['scn'] = {
+      id: _util.OPS.setFillColorN,
+      numArgs: 33,
+      variableArgs: true
+    };
+    t['G'] = {
+      id: _util.OPS.setStrokeGray,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['g'] = {
+      id: _util.OPS.setFillGray,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['RG'] = {
+      id: _util.OPS.setStrokeRGBColor,
+      numArgs: 3,
+      variableArgs: false
+    };
+    t['rg'] = {
+      id: _util.OPS.setFillRGBColor,
+      numArgs: 3,
+      variableArgs: false
+    };
+    t['K'] = {
+      id: _util.OPS.setStrokeCMYKColor,
+      numArgs: 4,
+      variableArgs: false
+    };
+    t['k'] = {
+      id: _util.OPS.setFillCMYKColor,
+      numArgs: 4,
+      variableArgs: false
+    };
+    t['sh'] = {
+      id: _util.OPS.shadingFill,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['BI'] = {
+      id: _util.OPS.beginInlineImage,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['ID'] = {
+      id: _util.OPS.beginImageData,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['EI'] = {
+      id: _util.OPS.endInlineImage,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['Do'] = {
+      id: _util.OPS.paintXObject,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['MP'] = {
+      id: _util.OPS.markPoint,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['DP'] = {
+      id: _util.OPS.markPointProps,
+      numArgs: 2,
+      variableArgs: false
+    };
+    t['BMC'] = {
+      id: _util.OPS.beginMarkedContent,
+      numArgs: 1,
+      variableArgs: false
+    };
+    t['BDC'] = {
+      id: _util.OPS.beginMarkedContentProps,
+      numArgs: 2,
+      variableArgs: false
+    };
+    t['EMC'] = {
+      id: _util.OPS.endMarkedContent,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['BX'] = {
+      id: _util.OPS.beginCompat,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['EX'] = {
+      id: _util.OPS.endCompat,
+      numArgs: 0,
+      variableArgs: false
+    };
+    t['BM'] = null;
+    t['BD'] = null;
+    t['true'] = null;
+    t['fa'] = null;
+    t['fal'] = null;
+    t['fals'] = null;
+    t['false'] = null;
+    t['nu'] = null;
+    t['nul'] = null;
+    t['null'] = null;
+  });
+  function EvaluatorPreprocessor(stream, xref, stateManager) {
+    this.opMap = getOPMap();
+    this.parser = new _parser.Parser(new _parser.Lexer(stream, this.opMap), false, xref);
+    this.stateManager = stateManager;
+    this.nonProcessedArgs = [];
+  }
+  EvaluatorPreprocessor.prototype = {
+    get savedStatesDepth() {
+      return this.stateManager.stateStack.length;
+    },
+    read: function EvaluatorPreprocessor_read(operation) {
+      var args = operation.args;
+      while (true) {
+        var obj = this.parser.getObj();
+        if ((0, _primitives.isCmd)(obj)) {
+          var cmd = obj.cmd;
+          var opSpec = this.opMap[cmd];
+          if (!opSpec) {
+            (0, _util.warn)('Unknown command "' + cmd + '"');
+            continue;
+          }
+          var fn = opSpec.id;
+          var numArgs = opSpec.numArgs;
+          var argsLength = args !== null ? args.length : 0;
+          if (!opSpec.variableArgs) {
+            if (argsLength !== numArgs) {
+              var nonProcessedArgs = this.nonProcessedArgs;
+              while (argsLength > numArgs) {
+                nonProcessedArgs.push(args.shift());
+                argsLength--;
+              }
+              while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
+                if (args === null) {
+                  args = [];
+                }
+                args.unshift(nonProcessedArgs.pop());
+                argsLength++;
+              }
+            }
+            if (argsLength < numArgs) {
+              (0, _util.warn)('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
+              if (args !== null) {
+                args.length = 0;
+              }
+              continue;
+            }
+          } else if (argsLength > numArgs) {
+            (0, _util.info)('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
+          }
+          this.preprocessCommand(fn, args);
+          operation.fn = fn;
+          operation.args = args;
+          return true;
+        }
+        if ((0, _primitives.isEOF)(obj)) {
+          return false;
+        }
+        if (obj !== null) {
+          if (args === null) {
+            args = [];
+          }
+          args.push(obj);
+          if (args.length > 33) {
+            throw new _util.FormatError('Too many arguments');
+          }
+        }
+      }
+    },
+    preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
+      switch (fn | 0) {
+        case _util.OPS.save:
+          this.stateManager.save();
+          break;
+        case _util.OPS.restore:
+          this.stateManager.restore();
+          break;
+        case _util.OPS.transform:
+          this.stateManager.transform(args);
+          break;
+      }
+    }
+  };
+  return EvaluatorPreprocessor;
+}();
+exports.PartialEvaluator = PartialEvaluator;
+
+/***/ }),
+/* 31 */
+/***/ (function(module, exports, __w_pdfjs_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
 exports.CMapFactory = exports.IdentityCMap = exports.CMap = undefined;
 
 var _util = __w_pdfjs_require__(0);
 
 var _primitives = __w_pdfjs_require__(1);
 
 var _parser = __w_pdfjs_require__(5);
 
@@ -31152,44 +31938,44 @@ var CMapFactory = function CMapFactoryCl
     }
   };
 }();
 exports.CMap = CMap;
 exports.IdentityCMap = IdentityCMap;
 exports.CMapFactory = CMapFactory;
 
 /***/ }),
-/* 30 */
+/* 32 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.getFontType = exports.ProblematicCharRanges = exports.IdentityToUnicodeMap = exports.ToUnicodeMap = exports.FontFlags = exports.Font = exports.ErrorFont = exports.PRIVATE_USE_OFFSET_END = exports.PRIVATE_USE_OFFSET_START = exports.SEAC_ANALYSIS_ENABLED = undefined;
 
 var _util = __w_pdfjs_require__(0);
 
 var _cff_parser = __w_pdfjs_require__(13);
 
-var _glyphlist = __w_pdfjs_require__(6);
+var _glyphlist = __w_pdfjs_require__(7);
 
 var _encodings = __w_pdfjs_require__(4);
 
 var _standard_fonts = __w_pdfjs_require__(14);
 
 var _unicode = __w_pdfjs_require__(15);
 
-var _font_renderer = __w_pdfjs_require__(32);
+var _font_renderer = __w_pdfjs_require__(34);
 
 var _stream = __w_pdfjs_require__(2);
 
-var _type1_parser = __w_pdfjs_require__(33);
+var _type1_parser = __w_pdfjs_require__(35);
 
 var PRIVATE_USE_OFFSET_START = 0xE000;
 var PRIVATE_USE_OFFSET_END = 0xF8FF;
 var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
 var PDF_GLYPH_SPACE_UNITS = 1000;
 var SEAC_ANALYSIS_ENABLED = false;
 var FontFlags = {
   FixedPitch: 1,
@@ -33625,49 +34411,49 @@ exports.ErrorFont = ErrorFont;
 exports.Font = Font;
 exports.FontFlags = FontFlags;
 exports.ToUnicodeMap = ToUnicodeMap;
 exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
 exports.ProblematicCharRanges = ProblematicCharRanges;
 exports.getFontType = getFontType;
 
 /***/ }),
-/* 31 */
+/* 33 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 var ISOAdobeCharset = ['.notdef', 'space', 'exclam', 'quotedbl', 'numbersign', 'dollar', 'percent', 'ampersand', 'quoteright', 'parenleft', 'parenright', 'asterisk', 'plus', 'comma', 'hyphen', 'period', 'slash', 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon', 'less', 'equal', 'greater', 'question', 'at', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'bracketleft', 'backslash', 'bracketright', 'asciicircum', 'underscore', 'quoteleft', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'braceleft', 'bar', 'braceright', 'asciitilde', 'exclamdown', 'cent', 'sterling', 'fraction', 'yen', 'florin', 'section', 'currency', 'quotesingle', 'quotedblleft', 'guillemotleft', 'guilsinglleft', 'guilsinglright', 'fi', 'fl', 'endash', 'dagger', 'daggerdbl', 'periodcentered', 'paragraph', 'bullet', 'quotesinglbase', 'quotedblbase', 'quotedblright', 'guillemotright', 'ellipsis', 'perthousand', 'questiondown', 'grave', 'acute', 'circumflex', 'tilde', 'macron', 'breve', 'dotaccent', 'dieresis', 'ring', 'cedilla', 'hungarumlaut', 'ogonek', 'caron', 'emdash', 'AE', 'ordfeminine', 'Lslash', 'Oslash', 'OE', 'ordmasculine', 'ae', 'dotlessi', 'lslash', 'oslash', 'oe', 'germandbls', 'onesuperior', 'logicalnot', 'mu', 'trademark', 'Eth', 'onehalf', 'plusminus', 'Thorn', 'onequarter', 'divide', 'brokenbar', 'degree', 'thorn', 'threequarters', 'twosuperior', 'registered', 'minus', 'eth', 'multiply', 'threesuperior', 'copyright', 'Aacute', 'Acircumflex', 'Adieresis', 'Agrave', 'Aring', 'Atilde', 'Ccedilla', 'Eacute', 'Ecircumflex', 'Edieresis', 'Egrave', 'Iacute', 'Icircumflex', 'Idieresis', 'Igrave', 'Ntilde', 'Oacute', 'Ocircumflex', 'Odieresis', 'Ograve', 'Otilde', 'Scaron', 'Uacute', 'Ucircumflex', 'Udieresis', 'Ugrave', 'Yacute', 'Ydieresis', 'Zcaron', 'aacute', 'acircumflex', 'adieresis', 'agrave', 'aring', 'atilde', 'ccedilla', 'eacute', 'ecircumflex', 'edieresis', 'egrave', 'iacute', 'icircumflex', 'idieresis', 'igrave', 'ntilde', 'oacute', 'ocircumflex', 'odieresis', 'ograve', 'otilde', 'scaron', 'uacute', 'ucircumflex', 'udieresis', 'ugrave', 'yacute', 'ydieresis', 'zcaron'];
 var ExpertCharset = ['.notdef', 'space', 'exclamsmall', 'Hungarumlautsmall', 'dollaroldstyle', 'dollarsuperior', 'ampersandsmall', 'Acutesmall', 'parenleftsuperior', 'parenrightsuperior', 'twodotenleader', 'onedotenleader', 'comma', 'hyphen', 'period', 'fraction', 'zerooldstyle', 'oneoldstyle', 'twooldstyle', 'threeoldstyle', 'fouroldstyle', 'fiveoldstyle', 'sixoldstyle', 'sevenoldstyle', 'eightoldstyle', 'nineoldstyle', 'colon', 'semicolon', 'commasuperior', 'threequartersemdash', 'periodsuperior', 'questionsmall', 'asuperior', 'bsuperior', 'centsuperior', 'dsuperior', 'esuperior', 'isuperior', 'lsuperior', 'msuperior', 'nsuperior', 'osuperior', 'rsuperior', 'ssuperior', 'tsuperior', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'parenleftinferior', 'parenrightinferior', 'Circumflexsmall', 'hyphensuperior', 'Gravesmall', 'Asmall', 'Bsmall', 'Csmall', 'Dsmall', 'Esmall', 'Fsmall', 'Gsmall', 'Hsmall', 'Ismall', 'Jsmall', 'Ksmall', 'Lsmall', 'Msmall', 'Nsmall', 'Osmall', 'Psmall', 'Qsmall', 'Rsmall', 'Ssmall', 'Tsmall', 'Usmall', 'Vsmall', 'Wsmall', 'Xsmall', 'Ysmall', 'Zsmall', 'colonmonetary', 'onefitted', 'rupiah', 'Tildesmall', 'exclamdownsmall', 'centoldstyle', 'Lslashsmall', 'Scaronsmall', 'Zcaronsmall', 'Dieresissmall', 'Brevesmall', 'Caronsmall', 'Dotaccentsmall', 'Macronsmall', 'figuredash', 'hypheninferior', 'Ogoneksmall', 'Ringsmall', 'Cedillasmall', 'onequarter', 'onehalf', 'threequarters', 'questiondownsmall', 'oneeighth', 'threeeighths', 'fiveeighths', 'seveneighths', 'onethird', 'twothirds', 'zerosuperior', 'onesuperior', 'twosuperior', 'threesuperior', 'foursuperior', 'fivesuperior', 'sixsuperior', 'sevensuperior', 'eightsuperior', 'ninesuperior', 'zeroinferior', 'oneinferior', 'twoinferior', 'threeinferior', 'fourinferior', 'fiveinferior', 'sixinferior', 'seveninferior', 'eightinferior', 'nineinferior', 'centinferior', 'dollarinferior', 'periodinferior', 'commainferior', 'Agravesmall', 'Aacutesmall', 'Acircumflexsmall', 'Atildesmall', 'Adieresissmall', 'Aringsmall', 'AEsmall', 'Ccedillasmall', 'Egravesmall', 'Eacutesmall', 'Ecircumflexsmall', 'Edieresissmall', 'Igravesmall', 'Iacutesmall', 'Icircumflexsmall', 'Idieresissmall', 'Ethsmall', 'Ntildesmall', 'Ogravesmall', 'Oacutesmall', 'Ocircumflexsmall', 'Otildesmall', 'Odieresissmall', 'OEsmall', 'Oslashsmall', 'Ugravesmall', 'Uacutesmall', 'Ucircumflexsmall', 'Udieresissmall', 'Yacutesmall', 'Thornsmall', 'Ydieresissmall'];
 var ExpertSubsetCharset = ['.notdef', 'space', 'dollaroldstyle', 'dollarsuperior', 'parenleftsuperior', 'parenrightsuperior', 'twodotenleader', 'onedotenleader', 'comma', 'hyphen', 'period', 'fraction', 'zerooldstyle', 'oneoldstyle', 'twooldstyle', 'threeoldstyle', 'fouroldstyle', 'fiveoldstyle', 'sixoldstyle', 'sevenoldstyle', 'eightoldstyle', 'nineoldstyle', 'colon', 'semicolon', 'commasuperior', 'threequartersemdash', 'periodsuperior', 'asuperior', 'bsuperior', 'centsuperior', 'dsuperior', 'esuperior', 'isuperior', 'lsuperior', 'msuperior', 'nsuperior', 'osuperior', 'rsuperior', 'ssuperior', 'tsuperior', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'parenleftinferior', 'parenrightinferior', 'hyphensuperior', 'colonmonetary', 'onefitted', 'rupiah', 'centoldstyle', 'figuredash', 'hypheninferior', 'onequarter', 'onehalf', 'threequarters', 'oneeighth', 'threeeighths', 'fiveeighths', 'seveneighths', 'onethird', 'twothirds', 'zerosuperior', 'onesuperior', 'twosuperior', 'threesuperior', 'foursuperior', 'fivesuperior', 'sixsuperior', 'sevensuperior', 'eightsuperior', 'ninesuperior', 'zeroinferior', 'oneinferior', 'twoinferior', 'threeinferior', 'fourinferior', 'fiveinferior', 'sixinferior', 'seveninferior', 'eightinferior', 'nineinferior', 'centinferior', 'dollarinferior', 'periodinferior', 'commainferior'];
 exports.ISOAdobeCharset = ISOAdobeCharset;
 exports.ExpertCharset = ExpertCharset;
 exports.ExpertSubsetCharset = ExpertSubsetCharset;
 
 /***/ }),
-/* 32 */
+/* 34 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.FontRendererFactory = undefined;
 
 var _util = __w_pdfjs_require__(0);
 
 var _cff_parser = __w_pdfjs_require__(13);
 
-var _glyphlist = __w_pdfjs_require__(6);
+var _glyphlist = __w_pdfjs_require__(7);
 
 var _encodings = __w_pdfjs_require__(4);
 
 var _stream = __w_pdfjs_require__(2);
 
 var FontRendererFactory = function FontRendererFactoryClosure() {
   function getLong(data, offset) {
     return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
@@ -34382,17 +35168,17 @@ var FontRendererFactory = function FontR
       }
       return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
     }
   };
 }();
 exports.FontRendererFactory = FontRendererFactory;
 
 /***/ }),
-/* 33 */
+/* 35 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -34945,17 +35731,17 @@ var Type1Parser = function Type1ParserCl
       }
     }
   };
   return Type1Parser;
 }();
 exports.Type1Parser = Type1Parser;
 
 /***/ }),
-/* 34 */
+/* 36 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -35735,17 +36521,17 @@ function getTilingPatternIR(operatorList
     throw new _util.FormatError(`Invalid getTilingPatternIR /BBox array: [${bbox}].`);
   }
   return ['TilingPattern', args, operatorList, matrix, bbox, xstep, ystep, paintType, tilingType];
 }
 exports.Pattern = Pattern;
 exports.getTilingPatternIR = getTilingPatternIR;
 
 /***/ }),
-/* 35 */
+/* 37 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -35980,17 +36766,17 @@ function bidi(str, startLevel, vertical)
       chars[i] = '';
     }
   }
   return createBidiText(chars.join(''), isLTR);
 }
 exports.bidi = bidi;
 
 /***/ }),
-/* 36 */
+/* 38 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -38934,17 +39720,17 @@ var getMetrics = (0, _util.getLookupTabl
     t['a189'] = 927;
     t['a190'] = 970;
     t['a191'] = 918;
   });
 });
 exports.getMetrics = getMetrics;
 
 /***/ }),
-/* 37 */
+/* 39 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -39138,17 +39924,17 @@ var PostScriptLexer = function PostScrip
     }
   };
   return PostScriptLexer;
 }();
 exports.PostScriptLexer = PostScriptLexer;
 exports.PostScriptParser = PostScriptParser;
 
 /***/ }),
-/* 38 */
+/* 40 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -39256,17 +40042,17 @@ var MurmurHash3_64 = function MurmurHash
       return str;
     }
   };
   return MurmurHash3_64;
 }();
 exports.MurmurHash3_64 = MurmurHash3_64;
 
 /***/ }),
-/* 39 */
+/* 41 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -39275,17 +40061,17 @@ exports.PDFImage = undefined;
 var _util = __w_pdfjs_require__(0);
 
 var _stream = __w_pdfjs_require__(2);
 
 var _primitives = __w_pdfjs_require__(1);
 
 var _colorspace = __w_pdfjs_require__(3);
 
-var _jpx = __w_pdfjs_require__(9);
+var _jpx = __w_pdfjs_require__(10);
 
 var PDFImage = function PDFImageClosure() {
   function handleImageData(image, nativeDecoder) {
     if (nativeDecoder && nativeDecoder.canDecode(image)) {
       return nativeDecoder.decode(image);
     }
     return Promise.resolve(image);
   }
@@ -39763,660 +40549,11 @@ var PDFImage = function PDFImageClosure(
       this.image.forceRGB = !!forceRGB;
       return this.image.getBytes(length);
     }
   };
   return PDFImage;
 }();
 exports.PDFImage = PDFImage;
 
-/***/ }),
-/* 40 */
-/***/ (function(module, exports, __w_pdfjs_require__) {
-
-"use strict";
-
-
-Object.defineProperty(exports, "__esModule", {
-  value: true
-});
-exports.AnnotationFactory = exports.AnnotationBorderStyle = exports.Annotation = undefined;
-
-var _util = __w_pdfjs_require__(0);
-
-var _obj = __w_pdfjs_require__(8);
-
-var _primitives = __w_pdfjs_require__(1);
-
-var _colorspace = __w_pdfjs_require__(3);
-
-var _evaluator = __w_pdfjs_require__(12);
-
-var _stream = __w_pdfjs_require__(2);
-
-class AnnotationFactory {
-  static create(xref, ref, pdfManager, idFactory) {
-    let dict = xref.fetchIfRef(ref);
-    if (!(0, _primitives.isDict)(dict)) {
-      return;
-    }
-    let id = (0, _primitives.isRef)(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
-    let subtype = dict.get('Subtype');
-    subtype = (0, _primitives.isName)(subtype) ? subtype.name : null;
-    let parameters = {
-      xref,
-      dict,
-      ref: (0, _primitives.isRef)(ref) ? ref : null,
-      subtype,
-      id,
-      pdfManager
-    };
-    switch (subtype) {
-      case 'Link':
-        return new LinkAnnotation(parameters);
-      case 'Text':
-        return new TextAnnotation(parameters);
-      case 'Widget':
-        let fieldType = _util.Util.getInheritableProperty(dict, 'FT');
-        fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null;
-        switch (fieldType) {
-          case 'Tx':
-            return new TextWidgetAnnotation(parameters);
-          case 'Btn':
-            return new ButtonWidgetAnnotation(parameters);
-          case 'Ch':
-            return new ChoiceWidgetAnnotation(parameters);
-        }
-        (0, _util.warn)('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
-        return new WidgetAnnotation(parameters);
-      case 'Popup':
-        return new PopupAnnotation(parameters);
-      case 'Line':
-        return new LineAnnotation(parameters);
-      case 'Square':
-        return new SquareAnnotation(parameters);
-      case 'Circle':
-        return new CircleAnnotation(parameters);
-      case 'PolyLine':
-        return new PolylineAnnotation(parameters);
-      case 'Polygon':
-        return new PolygonAnnotation(parameters);
-      case 'Highlight':
-        return new HighlightAnnotation(parameters);
-      case 'Underline':
-        return new UnderlineAnnotation(parameters);
-      case 'Squiggly':
-        return new SquigglyAnnotation(parameters);
-      case 'StrikeOut':
-        return new StrikeOutAnnotation(parameters);
-      case 'Stamp':
-        return new StampAnnotation(parameters);
-      case 'FileAttachment':
-        return new FileAttachmentAnnotation(parameters);
-      default:
-        if (!subtype) {
-          (0, _util.warn)('Annotation is missing the required /Subtype.');
-        } else {
-          (0, _util.warn)('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
-        }
-        return new Annotation(parameters);
-    }
-  }
-}
-function getTransformMatrix(rect, bbox, matrix) {
-  let bounds = _util.Util.getAxialAlignedBoundingBox(bbox, matrix);
-  let minX = bounds[0];
-  let minY = bounds[1];
-  let maxX = bounds[2];
-  let maxY = bounds[3];
-  if (minX === maxX || minY === maxY) {
-    return [1, 0, 0, 1, rect[0], rect[1]];
-  }
-  let xRatio = (rect[2] - rect[0]) / (maxX - minX);
-  let yRatio = (rect[3] - rect[1]) / (maxY - minY);
-  return [xRatio, 0, 0, yRatio, rect[0] - minX * xRatio, rect[1] - minY * yRatio];
-}
-class Annotation {
-  constructor(params) {
-    let dict = params.dict;
-    this.setFlags(dict.get('F'));
-    this.setRectangle(dict.getArray('Rect'));
-    this.setColor(dict.getArray('C'));
-    this.setBorderStyle(dict);
-    this.setAppearance(dict);
-    this.data = {
-      annotationFlags: this.flags,
-      borderStyle: this.borderStyle,
-      color: this.color,
-      hasAppearance: !!this.appearance,
-      id: params.id,
-      rect: this.rectangle,
-      subtype: params.subtype
-    };
-  }
-  _hasFlag(flags, flag) {
-    return !!(flags & flag);
-  }
-  _isViewable(flags) {
-    return !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, _util.AnnotationFlag.HIDDEN) && !this._hasFlag(flags, _util.AnnotationFlag.NOVIEW);
-  }
-  _isPrintable(flags) {
-    return this._hasFlag(flags, _util.AnnotationFlag.PRINT) && !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, _util.AnnotationFlag.HIDDEN);
-  }
-  get viewable() {
-    if (this.flags === 0) {
-      return true;
-    }
-    return this._isViewable(this.flags);
-  }
-  get printable() {
-    if (this.flags === 0) {
-      return false;
-    }
-    return this._isPrintable(this.flags);
-  }
-  setFlags(flags) {
-    this.flags = Number.isInteger(flags) && flags > 0 ? flags : 0;
-  }
-  hasFlag(flag) {
-    return this._hasFlag(this.flags, flag);
-  }
-  setRectangle(rectangle) {
-    if (Array.isArray(rectangle) && rectangle.length === 4) {
-      this.rectangle = _util.Util.normalizeRect(rectangle);
-    } else {
-      this.rectangle = [0, 0, 0, 0];
-    }
-  }
-  setColor(color) {
-    let rgbColor = new Uint8Array(3);
-    if (!Array.isArray(color)) {
-      this.color = rgbColor;
-      return;
-    }
-    switch (color.length) {
-      case 0:
-        this.color = null;
-        break;
-      case 1:
-        _colorspace.ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
-        this.color = rgbColor;
-        break;
-      case 3:
-        _colorspace.ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
-        this.color = rgbColor;
-        break;
-      case 4:
-        _colorspace.ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
-        this.color = rgbColor;
-        break;
-      default:
-        this.color = rgbColor;
-        break;
-    }
-  }
-  setBorderStyle(borderStyle) {
-    this.borderStyle = new AnnotationBorderStyle();
-    if (!(0, _primitives.isDict)(borderStyle)) {
-      return;
-    }
-    if (borderStyle.has('BS')) {
-      let dict = borderStyle.get('BS');
-      let dictType = dict.get('Type');
-      if (!dictType || (0, _primitives.isName)(dictType, 'Border')) {
-        this.borderStyle.setWidth(dict.get('W'));
-        this.borderStyle.setStyle(dict.get('S'));
-        this.borderStyle.setDashArray(dict.getArray('D'));
-      }
-    } else if (borderStyle.has('Border')) {
-      let array = borderStyle.getArray('Border');
-      if (Array.isArray(array) && array.length >= 3) {
-        this.borderStyle.setHorizontalCornerRadius(array[0]);
-        this.borderStyle.setVerticalCornerRadius(array[1]);
-        this.borderStyle.setWidth(array[2]);
-        if (array.length === 4) {
-          this.borderStyle.setDashArray(array[3]);
-        }
-      }
-    } else {
-      this.borderStyle.setWidth(0);
-    }
-  }
-  setAppearance(dict) {
-    this.appearance = null;
-    let appearanceStates = dict.get('AP');
-    if (!(0, _primitives.isDict)(appearanceStates)) {
-      return;
-    }
-    let normalAppearanceState = appearanceStates.get('N');
-    if ((0, _primitives.isStream)(normalAppearanceState)) {
-      this.appearance = normalAppearanceState;
-      return;
-    }
-    if (!(0, _primitives.isDict)(normalAppearanceState)) {
-      return;
-    }
-    let as = dict.get('AS');
-    if (!(0, _primitives.isName)(as) || !normalAppearanceState.has(as.name)) {
-      return;
-    }
-    this.appearance = normalAppearanceState.get(as.name);
-  }
-  _preparePopup(dict) {
-    if (!dict.has('C')) {
-      this.data.color = null;
-    }
-    this.data.hasPopup = dict.has('Popup');
-    this.data.title = (0, _util.stringToPDFString)(dict.get('T') || '');
-    this.data.contents = (0, _util.stringToPDFString)(dict.get('Contents') || '');
-  }
-  loadResources(keys) {
-    return this.appearance.dict.getAsync('Resources').then(resources => {
-      if (!resources) {
-        return;
-      }
-      let objectLoader = new _obj.ObjectLoader(resources, keys, resources.xref);
-      return objectLoader.load().then(function () {
-        return resources;
-      });
-    });
-  }
-  getOperatorList(evaluator, task, renderForms) {
-    if (!this.appearance) {
-      return Promise.resolve(new _evaluator.OperatorList());
-    }
-    let data = this.data;
-    let appearanceDict = this.appearance.dict;
-    let resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']);
-    let bbox = appearanceDict.getArray('BBox') || [0, 0, 1, 1];
-    let matrix = appearanceDict.getArray('Matrix') || [1, 0, 0, 1, 0, 0];
-    let transform = getTransformMatrix(data.rect, bbox, matrix);
-    return resourcesPromise.then(resources => {
-      let opList = new _evaluator.OperatorList();
-      opList.addOp(_util.OPS.beginAnnotation, [data.rect, transform, matrix]);
-      return evaluator.getOperatorList({
-        stream: this.appearance,
-        task,
-        resources,
-        operatorList: opList
-      }).then(() => {
-        opList.addOp(_util.OPS.endAnnotation, []);
-        this.appearance.reset();
-        return opList;
-      });
-    });
-  }
-}
-class AnnotationBorderStyle {
-  constructor() {
-    this.width = 1;
-    this.style = _util.AnnotationBorderStyleType.SOLID;
-    this.dashArray = [3];
-    this.horizontalCornerRadius = 0;
-    this.verticalCornerRadius = 0;
-  }
-  setWidth(width) {
-    if (Number.isInteger(width)) {
-      this.width = width;
-    }
-  }
-  setStyle(style) {
-    if (!style) {
-      return;
-    }
-    switch (style.name) {
-      case 'S':
-        this.style = _util.AnnotationBorderStyleType.SOLID;
-        break;
-      case 'D':
-        this.style = _util.AnnotationBorderStyleType.DASHED;
-        break;
-      case 'B':
-        this.style = _util.AnnotationBorderStyleType.BEVELED;
-        break;
-      case 'I':
-        this.style = _util.AnnotationBorderStyleType.INSET;
-        break;
-      case 'U':
-        this.style = _util.AnnotationBorderStyleType.UNDERLINE;
-        break;
-      default:
-        break;
-    }
-  }
-  setDashArray(dashArray) {
-    if (Array.isArray(dashArray) && dashArray.length > 0) {
-      let isValid = true;
-      let allZeros = true;
-      for (let i = 0, len = dashArray.length; i < len; i++) {
-        let element = dashArray[i];
-        let validNumber = +element >= 0;
-        if (!validNumber) {
-          isValid = false;
-          break;
-        } else if (element > 0) {
-          allZeros = false;
-        }
-      }
-      if (isValid && !allZeros) {
-        this.dashArray = dashArray;
-      } else {
-        this.width = 0;
-      }
-    } else if (dashArray) {
-      this.width = 0;
-    }
-  }
-  setHorizontalCornerRadius(radius) {
-    if (Number.isInteger(radius)) {
-      this.horizontalCornerRadius = radius;
-    }
-  }
-  setVerticalCornerRadius(radius) {
-    if (Number.isInteger(radius)) {
-      this.verticalCornerRadius = radius;
-    }
-  }
-}
-class WidgetAnnotation extends Annotation {
-  constructor(params) {
-    super(params);
-    let dict = params.dict;
-    let data = this.data;
-    data.annotationType = _util.AnnotationType.WIDGET;
-    data.fieldName = this._constructFieldName(dict);
-    data.fieldValue = _util.Util.getInheritableProperty(dict, 'V', true);
-    data.alternativeText = (0, _util.stringToPDFString)(dict.get('TU') || '');
-    data.defaultAppearance = _util.Util.getInheritableProperty(dict, 'DA') || '';
-    let fieldType = _util.Util.getInheritableProperty(dict, 'FT');
-    data.fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null;
-    this.fieldResources = _util.Util.getInheritableProperty(dict, 'DR') || _primitives.Dict.empty;
-    data.fieldFlags = _util.Util.getInheritableProperty(dict, 'Ff');
-    if (!Number.isInteger(data.fieldFlags) || data.fieldFlags < 0) {
-      data.fieldFlags = 0;
-    }
-    data.readOnly = this.hasFieldFlag(_util.AnnotationFieldFlag.READONLY);
-    if (data.fieldType === 'Sig') {
-      this.setFlags(_util.AnnotationFlag.HIDDEN);
-    }
-  }
-  _constructFieldName(dict) {
-    if (!dict.has('T') && !dict.has('Parent')) {
-      (0, _util.warn)('Unknown field name, falling back to empty field name.');
-      return '';
-    }
-    if (!dict.has('Parent')) {
-      return (0, _util.stringToPDFString)(dict.get('T'));
-    }
-    let fieldName = [];
-    if (dict.has('T')) {
-      fieldName.unshift((0, _util.stringToPDFString)(dict.get('T')));
-    }
-    let loopDict = dict;
-    while (loopDict.has('Parent')) {
-      loopDict = loopDict.get('Parent');
-      if (!(0, _primitives.isDict)(loopDict)) {
-        break;
-      }
-      if (loopDict.has('T')) {
-        fieldName.unshift((0, _util.stringToPDFString)(loopDict.get('T')));
-      }
-    }
-    return fieldName.join('.');
-  }
-  hasFieldFlag(flag) {
-    return !!(this.data.fieldFlags & flag);
-  }
-  getOperatorList(evaluator, task, renderForms) {
-    if (renderForms) {
-      return Promise.resolve(new _evaluator.OperatorList());
-    }
-    return super.getOperatorList(evaluator, task, renderForms);
-  }
-}
-class TextWidgetAnnotation extends WidgetAnnotation {
-  constructor(params) {
-    super(params);
-    this.data.fieldValue = (0, _util.stringToPDFString)(this.data.fieldValue || '');
-    let alignment = _util.Util.getInheritableProperty(params.dict, 'Q');
-    if (!Number.isInteger(alignment) || alignment < 0 || alignment > 2) {
-      alignment = null;
-    }
-    this.data.textAlignment = alignment;
-    let maximumLength = _util.Util.getInheritableProperty(params.dict, 'MaxLen');
-    if (!Number.isInteger(maximumLength) || maximumLength < 0) {
-      maximumLength = null;
-    }
-    this.data.maxLen = maximumLength;
-    this.data.multiLine = this.hasFieldFlag(_util.AnnotationFieldFlag.MULTILINE);
-    this.data.comb = this.hasFieldFlag(_util.AnnotationFieldFlag.COMB) && !this.hasFieldFlag(_util.AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(_util.AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(_util.AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
-  }
-  getOperatorList(evaluator, task, renderForms) {
-    if (renderForms || this.appearance) {
-      return super.getOperatorList(evaluator, task, renderForms);
-    }
-    let operatorList = new _evaluator.OperatorList();
-    if (!this.data.defaultAppearance) {
-      return Promise.resolve(operatorList);
-    }
-    let stream = new _stream.Stream((0, _util.stringToBytes)(this.data.defaultAppearance));
-    return evaluator.getOperatorList({
-      stream,
-      task,
-      resources: this.fieldResources,
-      operatorList
-    }).then(function () {
-      return operatorList;
-    });
-  }
-}
-class ButtonWidgetAnnotation extends WidgetAnnotation {
-  constructor(params) {
-    super(params);
-    this.data.checkBox = !this.hasFieldFlag(_util.AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
-    if (this.data.checkBox) {
-      if (!(0, _primitives.isName)(this.data.fieldValue)) {
-        return;
-      }
-      this.data.fieldValue = this.data.fieldValue.name;
-    }
-    this.data.radioButton = this.hasFieldFlag(_util.AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
-    if (this.data.radioButton) {
-      this.data.fieldValue = this.data.buttonValue = null;
-      let fieldParent = params.dict.get('Parent');
-      if ((0, _primitives.isDict)(fieldParent) && fieldParent.has('V')) {
-        let fieldParentValue = fieldParent.get('V');
-        if ((0, _primitives.isName)(fieldParentValue)) {
-          this.data.fieldValue = fieldParentValue.name;
-        }
-      }
-      let appearanceStates = params.dict.get('AP');
-      if (!(0, _primitives.isDict)(appearanceStates)) {
-        return;
-      }
-      let normalAppearanceState = appearanceStates.get('N');
-      if (!(0, _primitives.isDict)(normalAppearanceState)) {
-        return;
-      }
-      let keys = normalAppearanceState.getKeys();
-      for (let i = 0, ii = keys.length; i < ii; i++) {
-        if (keys[i] !== 'Off') {
-          this.data.buttonValue = keys[i];
-          break;
-        }
-      }
-    }
-  }
-}
-class ChoiceWidgetAnnotation extends WidgetAnnotation {
-  constructor(params) {
-    super(params);
-    this.data.options = [];
-    let options = _util.Util.getInheritableProperty(params.dict, 'Opt');
-    if (Array.isArray(options)) {
-      let xref = params.xref;
-      for (let i = 0, ii = options.length; i < ii; i++) {
-        let option = xref.fetchIfRef(options[i]);
-        let isOptionArray = Array.isArray(option);
-        this.data.options[i] = {
-          exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
-          displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
-        };
-      }
-    }
-    if (!Array.isArray(this.data.fieldValue)) {
-      this.data.fieldValue = [this.data.fieldValue];
-    }
-    this.data.combo = this.hasFieldFlag(_util.AnnotationFieldFlag.COMBO);
-    this.data.multiSelect = this.hasFieldFlag(_util.AnnotationFieldFlag.MULTISELECT);
-  }
-}
-class TextAnnotation extends Annotation {
-  constructor(parameters) {
-    const DEFAULT_ICON_SIZE = 22;
-    super(parameters);
-    this.data.annotationType = _util.AnnotationType.TEXT;
-    if (this.data.hasAppearance) {
-      this.data.name = 'NoIcon';
-    } else {
-      this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
-      this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
-      this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
-    }
-    this._preparePopup(parameters.dict);
-  }
-}
-class LinkAnnotation extends Annotation {
-  constructor(params) {
-    super(params);
-    this.data.annotationType = _util.AnnotationType.LINK;
-    _obj.Catalog.parseDestDictionary({
-      destDict: params.dict,
-      resultObj: this.data,
-      docBaseUrl: params.pdfManager.docBaseUrl
-    });
-  }
-}
-class PopupAnnotation extends Annotation {
-  constructor(parameters) {
-    super(parameters);
-    this.data.annotationType = _util.AnnotationType.POPUP;
-    let dict = parameters.dict;
-    let parentItem = dict.get('Parent');
-    if (!parentItem) {
-      (0, _util.warn)('Popup annotation has a missing or invalid parent annotation.');
-      return;
-    }
-    let parentSubtype = parentItem.get('Subtype');
-    this.data.parentType = (0, _primitives.isName)(parentSubtype) ? parentSubtype.name : null;
-    this.data.parentId = dict.getRaw('Parent').toString();
-    this.data.title = (0, _util.stringToPDFString)(parentItem.get('T') || '');
-    this.data.contents = (0, _util.stringToPDFString)(parentItem.get('Contents') || '');
-    if (!parentItem.has('C')) {
-      this.data.color = null;
-    } else {
-      this.setColor(parentItem.getArray('C'));
-      this.data.color = this.color;
-    }
-    if (!this.viewable) {
-      let parentFlags = parentItem.get('F');
-      if (this._isViewable(parentFlags)) {
-        this.setFlags(parentFlags);
-      }
-    }
-  }
-}
-class LineAnnotation extends Annotation {
-  constructor(parameters) {
-    super(parameters);
-    this.data.annotationType = _util.AnnotationType.LINE;
-    let dict = parameters.dict;
-    this.data.lineCoordinates = _util.Util.normalizeRect(dict.getArray('L'));
-    this._preparePopup(dict);
-  }
-}
-class SquareAnnotation extends Annotation {
-  constructor(parameters) {
-    super(parameters);
-    this.data.annotationType = _util.AnnotationType.SQUARE;
-    this._preparePopup(parameters.dict);
-  }
-}
-class CircleAnnotation extends Annotation {
-  constructor(parameters) {
-    super(parameters);
-    this.data.annotationType = _util.AnnotationType.CIRCLE;
-    this._preparePopup(parameters.dict);
-  }
-}
-class PolylineAnnotation extends Annotation {
-  constructor(parameters) {
-    super(parameters);
-    this.data.annotationType = _util.AnnotationType.POLYLINE;
-    let dict = parameters.dict;
-    let rawVertices = dict.getArray('Vertices');
-    this.data.vertices = [];
-    for (let i = 0, ii = rawVertices.length; i < ii; i += 2) {
-      this.data.vertices.push({
-        x: rawVertices[i],
-        y: rawVertices[i + 1]
-      });
-    }
-    this._preparePopup(dict);
-  }
-}
-class PolygonAnnotation extends PolylineAnnotation {
-  constructor(parameters) {
-    super(parameters);
-    this.data.annotationType = _util.AnnotationType.POLYGON;
-  }
-}
-class HighlightAnnotation extends Annotation {
-  constructor(parameters) {
-    super(parameters);
-    this.data.annotationType = _util.AnnotationType.HIGHLIGHT;
-    this._preparePopup(parameters.dict);
-  }
-}
-class UnderlineAnnotation extends Annotation {
-  constructor(parameters) {
-    super(parameters);
-    this.data.annotationType = _util.AnnotationType.UNDERLINE;
-    this._preparePopup(parameters.dict);
-  }
-}
-class SquigglyAnnotation extends Annotation {
-  constructor(parameters) {
-    super(parameters);
-    this.data.annotationType = _util.AnnotationType.SQUIGGLY;
-    this._preparePopup(parameters.dict);
-  }
-}
-class StrikeOutAnnotation extends Annotation {
-  constructor(parameters) {
-    super(parameters);
-    this.data.annotationType = _util.AnnotationType.STRIKEOUT;
-    this._preparePopup(parameters.dict);
-  }
-}
-class StampAnnotation extends Annotation {
-  constructor(parameters) {
-    super(parameters);
-    this.data.annotationType = _util.AnnotationType.STAMP;
-    this._preparePopup(parameters.dict);
-  }
-}
-class FileAttachmentAnnotation extends Annotation {
-  constructor(parameters) {
-    super(parameters);
-    let file = new _obj.FileSpec(parameters.dict.get('FS'), parameters.xref);
-    this.data.annotationType = _util.AnnotationType.FILEATTACHMENT;
-    this.data.file = file.serializable;
-    this._preparePopup(parameters.dict);
-  }
-}
-exports.Annotation = Annotation;
-exports.AnnotationBorderStyle = AnnotationBorderStyle;
-exports.AnnotationFactory = AnnotationFactory;
-
 /***/ })
 /******/ ]);
 });
\ No newline at end of file
--- a/browser/extensions/pdfjs/content/web/viewer.js
+++ b/browser/extensions/pdfjs/content/web/viewer.js
@@ -130,17 +130,16 @@ let NullL10n = {
     return Promise.resolve();
   }
 };
 _pdfjsLib.PDFJS.disableFullscreen = _pdfjsLib.PDFJS.disableFullscreen === undefined ? false : _pdfjsLib.PDFJS.disableFullscreen;
 _pdfjsLib.PDFJS.useOnlyCssZoom = _pdfjsLib.PDFJS.useOnlyCssZoom === undefined ? false : _pdfjsLib.PDFJS.useOnlyCssZoom;
 _pdfjsLib.PDFJS.maxCanvasPixels = _pdfjsLib.PDFJS.maxCanvasPixels === undefined ? 16777216 : _pdfjsLib.PDFJS.maxCanvasPixels;
 _pdfjsLib.PDFJS.disableHistory = _pdfjsLib.PDFJS.disableHistory === undefined ? false : _pdfjsLib.PDFJS.disableHistory;
 _pdfjsLib.PDFJS.disableTextLayer = _pdfjsLib.PDFJS.disableTextLayer === undefined ? false : _pdfjsLib.PDFJS.disableTextLayer;
-_pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom = _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom === undefined ? false : _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom;
 ;
 function getOutputScale(ctx) {
   let devicePixelRatio = window.devicePixelRatio || 1;
   let backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
   let pixelRatio = devicePixelRatio / backingStoreRatio;
   return {
     sx: pixelRatio,
     sy: pixelRatio,
@@ -1827,19 +1826,16 @@ function webViewerInitialized() {
       _pdfjsLib.PDFJS.disableWebGL = hashParams['webgl'] !== 'true';
     }
     if ('useonlycsszoom' in hashParams) {
       _pdfjsLib.PDFJS.useOnlyCssZoom = hashParams['useonlycsszoom'] === 'true';
     }
     if ('verbosity' in hashParams) {
       _pdfjsLib.PDFJS.verbosity = hashParams['verbosity'] | 0;
     }
-    if ('ignorecurrentpositiononzoom' in hashParams) {
-      _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom = hashParams['ignorecurrentpositiononzoom'] === 'true';
-    }
     if ('textlayer' in hashParams) {
       switch (hashParams['textlayer']) {
         case 'off':
           _pdfjsLib.PDFJS.disableTextLayer = true;
           break;
         case 'visible':
         case 'shadow':
         case 'hover':
@@ -5371,17 +5367,29 @@ class PDFThumbnailViewer {
     if (thumbnail) {
       thumbnail.classList.add('selected');
     }
     let visibleThumbs = this._getVisibleThumbs();
     let numVisibleThumbs = visibleThumbs.views.length;
     if (numVisibleThumbs > 0) {
       let first = visibleThumbs.first.id;
       let last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
+      let shouldScroll = false;
       if (page <= first || page >= last) {
+        shouldScroll = true;
+      } else {
+        visibleThumbs.views.some(function (view) {
+          if (view.id !== page) {
+            return false;
+          }
+          shouldScroll = view.percent < 100;
+          return true;
+        });
+      }
+      if (shouldScroll) {
         (0, _ui_utils.scrollIntoView)(thumbnail, { top: THUMBNAIL_SCROLL_MARGIN });
       }
     }
   }
   get pagesRotation() {
     return this._pagesRotation;
   }
   set pagesRotation(rotation) {
@@ -6238,17 +6246,17 @@ class BaseViewer {
     }
     for (let i = 0, ii = this._pages.length; i < ii; i++) {
       this._pages[i].update(newScale);
     }
     this._currentScale = newScale;
     if (!noScroll) {
       let page = this._currentPageNumber,
           dest;
-      if (this._location && !_pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
+      if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
         page = this._location.pageNumber;
         dest = [null, { name: 'XYZ' }, this._location.left, this._location.top, null];
       }
       this.scrollPageIntoView({
         pageNumber: page,
         destArray: dest,
         allowNegativeOffset: true
       });
--- a/browser/tools/mozscreenshots/moz.build
+++ b/browser/tools/mozscreenshots/moz.build
@@ -12,17 +12,17 @@ with Files("controlCenter/**"):
 
 with Files("devtools/**"):
     BUG_COMPONENT = ("Firefox", "Developer Tools")
 
 with Files("permissionPrompts/**"):
     BUG_COMPONENT = ("Firefox", "Site Identity and Permission Panels")
 
 with Files("preferences/**"):
-    BUG_COMPONENT = ("Firefox", "preferences")
+    BUG_COMPONENT = ("Firefox", "Preferences")
 
 BROWSER_CHROME_MANIFESTS += [
     # Each test is in it's own directory so it gets run in a clean profile with
     # run-by-dir.
     'browser.ini',
     'controlCenter/browser.ini',
     'devtools/browser.ini',
     'permissionPrompts/browser.ini',
--- a/build/autoconf/clang-plugin.m4
+++ b/build/autoconf/clang-plugin.m4
@@ -151,16 +151,36 @@ if test -n "$ENABLE_CLANG_PLUGIN"; then
       LLVM_CXXFLAGS="$LLVM_CXXFLAGS -DHAS_ACCEPTS_IGNORINGPARENIMPCASTS"
     fi
 
     CLANG_PLUGIN_FLAGS="-Xclang -load -Xclang $CLANG_PLUGIN -Xclang -add-plugin -Xclang moz-check"
 
     AC_DEFINE(MOZ_CLANG_PLUGIN)
 fi
 
+if test -n "$ENABLE_MOZSEARCH_PLUGIN"; then
+    if test -z "${ENABLE_CLANG_PLUGIN}"; then
+        AC_MSG_ERROR([Can't use mozsearch plugin without --enable-clang-plugin.])
+    fi
+
+    dnl We use this construct rather than $_objdir to avoid getting /js/src in the
+    dnl path when compiling JS code.
+    OBJDIR="$(dirname $(dirname $(dirname $CLANG_PLUGIN)))"
+
+    CLANG_PLUGIN_FLAGS="$CLANG_PLUGIN_FLAGS -Xclang -add-plugin -Xclang mozsearch-index"
+
+    dnl Parameters are: srcdir, outdir (path where output JSON is stored), objdir.
+    CLANG_PLUGIN_FLAGS="$CLANG_PLUGIN_FLAGS -Xclang -plugin-arg-mozsearch-index -Xclang $_topsrcdir"
+    CLANG_PLUGIN_FLAGS="$CLANG_PLUGIN_FLAGS -Xclang -plugin-arg-mozsearch-index -Xclang $OBJDIR/mozsearch_index"
+    CLANG_PLUGIN_FLAGS="$CLANG_PLUGIN_FLAGS -Xclang -plugin-arg-mozsearch-index -Xclang $OBJDIR"
+
+    AC_DEFINE(MOZ_MOZSEARCH_PLUGIN)
+fi
+
 AC_SUBST_LIST(CLANG_PLUGIN_FLAGS)
 AC_SUBST_LIST(LLVM_CXXFLAGS)
 AC_SUBST_LIST(LLVM_LDFLAGS)
 AC_SUBST_LIST(CLANG_LDFLAGS)
 
 AC_SUBST(ENABLE_CLANG_PLUGIN)
+AC_SUBST(ENABLE_MOZSEARCH_PLUGIN)
 
 ])
--- a/build/clang-plugin/moz.build
+++ b/build/clang-plugin/moz.build
@@ -36,16 +36,24 @@ UNIFIED_SOURCES += [
     'RefCountedCopyConstructorChecker.cpp',
     'RefCountedInsideLambdaChecker.cpp',
     'ScopeChecker.cpp',
     'SprintfLiteralChecker.cpp',
     'TrivialCtorDtorChecker.cpp',
     'VariableUsageHelpers.cpp',
 ]
 
+if CONFIG['ENABLE_MOZSEARCH_PLUGIN']:
+    UNIFIED_SOURCES += [
+        'mozsearch-plugin/FileOperations.cpp',
+        'mozsearch-plugin/JSONFormatter.cpp',
+        'mozsearch-plugin/MozsearchIndexer.cpp',
+        'mozsearch-plugin/StringOperations.cpp',
+    ]
+
 GENERATED_FILES += ['ThirdPartyPaths.cpp']
 third_party_paths = GENERATED_FILES['ThirdPartyPaths.cpp']
 third_party_paths.script = "ThirdPartyPaths.py:generate"
 third_party_paths.inputs = [
     '/tools/rewriting/ThirdPartyPaths.txt',
 ]
 
 DisableStlWrapping()
new file mode 100644
--- /dev/null
+++ b/build/clang-plugin/mozsearch-plugin/FileOperations.cpp
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "FileOperations.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#if defined(_WIN32) || defined(_WIN64)
+#include <direct.h>
+#include <io.h>
+#include <windows.h>
+#else
+#include <sys/file.h>
+#include <sys/time.h>
+#include <unistd.h>
+#endif
+
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+// Make sure that all directories on path exist, excluding the final element of
+// the path.
+void ensurePath(std::string Path) {
+  size_t Pos = 0;
+  if (Path[0] == '/') {
+    Pos++;
+  }
+
+  while ((Pos = Path.find('/', Pos)) != std::string::npos) {
+    std::string Portion = Path.substr(0, Pos);
+    if (!Portion.empty()) {
+#if defined(_WIN32) || defined(_WIN64)
+      int Err = _mkdir(Portion.c_str());
+#else
+      int Err = mkdir(Portion.c_str(), 0775);
+#endif
+      if (Err == -1 && errno != EEXIST) {
+        perror("mkdir failed");
+        exit(1);
+      }
+    }
+
+    Pos++;
+  }
+}
+
+#if defined(_WIN32) || defined(_WIN64)
+AutoLockFile::AutoLockFile(const std::string &Filename) {
+  std::string Hash = Hash(filename);
+  std::string MutexName = std::string("Local\\searchfox-") + Hash;
+  std::wstring WideMutexName;
+  WideMutexName.assign(MutexName.begin(), MutexName.end());
+  Handle = CreateMutex(nullptr, false, WideMutexName.c_str());
+  if (Handle == NULL) {
+    return;
+  }
+
+  WaitForSingleObject(Handle, INFINITE);
+
+  FileDescriptor = _open(Filename.c_str(), _O_RDWR | _O_CREAT, 0666);
+}
+
+AutoLockFile::~AutoLockFile() {
+  _close(FileDescriptor);
+
+  ReleaseMutex(Handle);
+  CloseHandle(Handle);
+}
+
+bool AutoLockFile::success() {
+  return Handle != NULL && FileDescriptor != -1;
+}
+
+FILE *AutoLockFile::openFile(const char *Mode) {
+  _lseek(FileDescriptor, 0, SEEK_SET);
+  return _fdopen(_dup(FileDescriptor), Mode);
+}
+
+bool AutoLockFile::truncateFile(size_t Length) {
+  return _chsize(FileDescriptor, Length) == 0;
+}
+
+std::string getAbsolutePath(const std::string &Filename) {
+  char full[_MAX_PATH];
+  if (!_fullpath(Full, Filename.c_str(), _MAX_PATH)) {
+    return std::string("");
+  }
+  return std::string(Full);
+}
+#else
+AutoLockFile::AutoLockFile(const std::string &Filename) {
+  FileDescriptor = open(Filename.c_str(), O_RDWR | O_CREAT, 0666);
+  if (FileDescriptor == -1) {
+    return;
+  }
+
+  do {
+    int rv = flock(FileDescriptor, LOCK_EX);
+    if (rv == 0) {
+      break;
+    }
+  } while (true);
+}
+
+AutoLockFile::~AutoLockFile() { close(FileDescriptor); }
+
+bool AutoLockFile::success() { return FileDescriptor != -1; }
+
+FILE *AutoLockFile::openFile(const char *Mode) {
+  lseek(FileDescriptor, 0, SEEK_SET);
+  return fdopen(dup(FileDescriptor), Mode);
+}
+
+bool AutoLockFile::truncateFile(size_t Length) {
+  return ftruncate(FileDescriptor, Length) == 0;
+}
+
+std::string getAbsolutePath(const std::string &Filename) {
+  char Full[4096];
+  if (!realpath(Filename.c_str(), Full)) {
+    return std::string("");
+  }
+  return std::string(Full);
+}
+#endif
new file mode 100644
--- /dev/null
+++ b/build/clang-plugin/mozsearch-plugin/FileOperations.h
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef FileOperations_h
+#define FileOperations_h
+
+#include <stdio.h>
+#include <string>
+
+#if defined(_WIN32) || defined(_WIN64)
+#include <windows.h>
+#endif
+
+// Make sure that all directories on path exist, excluding the final element of
+// the path.
+void ensurePath(std::string Path);
+
+std::string getAbsolutePath(const std::string &Filename);
+
+// Lock the given filename so that it cannot be opened by anyone else until this
+// object goes out of scope. On Windows, we use a named mutex. On POSIX
+// platforms, we use flock.
+struct AutoLockFile {
+  int FileDescriptor = -1;
+
+#if defined(_WIN32) || defined(_WIN64)
+  HANDLE Handle = NULL;
+#endif
+
+  AutoLockFile(const std::string &Filename);
+  ~AutoLockFile();
+
+  bool success();
+
+  FILE *openFile(const char *Mode);
+  bool truncateFile(size_t Length);
+};
+
+#endif
new file mode 100644
--- /dev/null
+++ b/build/clang-plugin/mozsearch-plugin/JSONFormatter.cpp
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "JSONFormatter.h"
+
+#include <algorithm>
+#include <cassert>
+#include <string.h>
+
+static std::string replaceAll(std::string Mangled, std::string Pattern,
+                              std::string Replacement) {
+  size_t Pos = 0;
+  while ((Pos = Mangled.find(Pattern, Pos)) != std::string::npos) {
+    Mangled = Mangled.replace(Pos, Pattern.length(), Replacement);
+    Pos += Replacement.length();
+  }
+  return Mangled;
+}
+
+/**
+ * Hacky escaping logic with the goal of not upsetting the much more thorough
+ * rust JSON parsing library that actually understands UTF-8.  Double-quote
+ * and (escaping) backslash are escaped, as is tab (\t), with newlines (\r\n
+ * and \n) normalized to escaped \n.
+ *
+ * Additionally, everything that's not printable ASCII is simply erased.  The
+ * motivating file is media/openmax_il/il112/OMX_Other.h#93 which has a
+ * corrupted apostrophe as <92> in there.  The better course of action would
+ * be a validating UTF-8 parse that discards corrupt/non-printable characters.
+ * Since this is motivated by a commenting proof-of-concept and builds are
+ * already slow, I'm punting on that.
+ */
+std::string JSONFormatter::escape(std::string Input) {
+  bool NeedsEscape = false;
+  for (char C : Input) {
+    if (C == '\\' || C == '"' || C < 32 || C > 126) {
+      NeedsEscape = true;
+      break;
+    }
+  }
+
+  if (!NeedsEscape) {
+    return Input;
+  }
+
+  std::string Cur = Input;
+  Cur = replaceAll(Cur, "\\", "\\\\");
+  Cur = replaceAll(Cur, "\"", "\\\"");
+  Cur = replaceAll(Cur, "\t", "\\t");
+  Cur = replaceAll(Cur, "\r\n", "\\n");
+  Cur = replaceAll(Cur, "\n", "\\n");
+  Cur.erase(std::remove_if(Cur.begin(), Cur.end(),
+                           [](char C){ return C < 32 || C > 126; }),
+            Cur.end());
+  return Cur;
+}
+
+void JSONFormatter::add(const char *Name, const char *Value) {
+  assert(PropertyCount < kMaxProperties);
+  Properties[PropertyCount] = Property(Name, std::string(Value));
+  PropertyCount++;
+
+  // `"Name":"Value",`
+  Length += strlen(Name) + 3 + strlen(Value) + 2 + 1;
+}
+
+void JSONFormatter::add(const char *Name, std::string Value) {
+  std::string Escaped = escape(std::move(Value));
+
+  // `"Name":"Escaped",`
+  Length += strlen(Name) + 3 + Escaped.length() + 2 + 1;
+
+  assert(PropertyCount < kMaxProperties);
+  Properties[PropertyCount] = Property(Name, std::move(Escaped));
+  PropertyCount++;
+}
+
+void JSONFormatter::add(const char *Name, int Value) {
+  // 1 digit
+  assert(Value >= 0 && Value < 10);
+
+  assert(PropertyCount < kMaxProperties);
+  Properties[PropertyCount] = Property(Name, Value);
+  PropertyCount++;
+
+  // `"Name":V,`
+  Length += strlen(Name) + 3 + 2;
+}
+
+void JSONFormatter::format(std::string &Result) {
+  Result.reserve(Length + 2);
+
+  Result.push_back('{');
+  for (int I = 0; I < PropertyCount; I++) {
+    Result.push_back('"');
+    Result.append(Properties[I].Name);
+    Result.push_back('"');
+    Result.push_back(':');
+
+    if (Properties[I].IsString) {
+      Result.push_back('"');
+      Result.append(Properties[I].StringValue);
+      Result.push_back('"');
+    } else {
+      Result.push_back(Properties[I].IntValue + '0');
+    }
+
+    if (I + 1 != PropertyCount) {
+      Result.push_back(',');
+    }
+  }
+
+  Result.push_back('}');
+  Result.push_back('\n');
+
+  assert(Result.length() == Length + 2);
+}
new file mode 100644
--- /dev/null
+++ b/build/clang-plugin/mozsearch-plugin/JSONFormatter.h
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef JSONFormatter_h
+#define JSONFormatter_h
+
+#include <memory>
+#include <string>
+
+// A very basic JSON formatter that records key/value pairs and outputs a JSON
+// object that contains only non-object data.
+class JSONFormatter {
+  // Of these fields, only mEscapedStringValue is owned by this class. All the
+  // others are expected to outlive the class (which is typically allocated
+  // on-stack).
+  struct Property {
+    const char *Name;
+    std::string StringValue;
+    int IntValue;
+    bool IsString;
+
+    Property() {}
+
+    Property(const char* Name, std::string String)
+      : Name(Name), StringValue(std::move(String)), IsString(true) {}
+
+    Property(const char* Name, int Int)
+      : Name(Name), IntValue(Int), IsString(false) {}
+  };
+
+  static const int kMaxProperties = 32;
+
+  Property Properties[kMaxProperties];
+  int PropertyCount;
+
+  // Length of the generated JSON output.
+  size_t Length;
+
+  std::string escape(std::string Input);
+
+public:
+  JSONFormatter() : PropertyCount(0), Length(0) {}
+
+  void add(const char *Name, const char *Value);
+  void add(const char *Name, std::string Value);
+  void add(const char *Name, int Value);
+
+  void format(std::string &Result);
+};
+
+#endif
new file mode 100644
--- /dev/null
+++ b/build/clang-plugin/mozsearch-plugin/MozsearchIndexer.cpp
@@ -0,0 +1,1492 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "clang/AST/AST.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/AST/Mangle.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/Version.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendPluginRegistry.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include <iostream>
+#include <map>
+#include <memory>
+#include <sstream>
+#include <tuple>
+#include <unordered_set>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "FileOperations.h"
+#include "JSONFormatter.h"
+#include "StringOperations.h"
+
+using namespace clang;
+
+const std::string GENERATED("__GENERATED__/");
+
+// Absolute path to directory containing source code.
+std::string Srcdir;
+
+// Absolute path to objdir (including generated code).
+std::string Objdir;
+
+// Absolute path where analysis JSON output will be stored.
+std::string Outdir;
+
+#if !defined(_WIN32) && !defined(_WIN64)
+#include <sys/time.h>
+
+static double time() {
+  struct timeval Tv;
+  gettimeofday(&Tv, nullptr);
+  return double(Tv.tv_sec) + double(Tv.tv_usec) / 1000000.;
+}
+#endif
+
+// Return true if |input| is a valid C++ identifier. We don't want to generate
+// analysis information for operators, string literals, etc. by accident since
+// it trips up consumers of the data.
+static bool isValidIdentifier(std::string Input) {
+  for (char C : Input) {
+    if (!(isalpha(C) || isdigit(C) || C == '_')) {
+      return false;
+    }
+  }
+  return true;
+}
+
+class IndexConsumer;
+
+// For each C++ file seen by the analysis (.cpp or .h), we track a
+// FileInfo. This object tracks whether the file is "interesting" (i.e., whether
+// it's in the source dir or the objdir). We also store the analysis output
+// here.
+struct FileInfo {
+  FileInfo(std::string &Rname) : Realname(Rname) {
+    if (Rname.compare(0, Objdir.length(), Objdir) == 0) {
+      // We're in the objdir, so we are probably a generated header
+      // We use the escape character to indicate the objdir nature.
+      // Note that output also has the `/' already placed
+      Interesting = true;
+      Realname.replace(0, Objdir.length(), GENERATED);
+      return;
+    }
+
+    Interesting = Rname.compare(0, Srcdir.length(), Srcdir) == 0;
+    if (Interesting) {
+      // Remove the trailing `/' as well.
+      Realname.erase(0, Srcdir.length() + 1);
+    }
+  }
+  std::string Realname;
+  std::vector<std::string> Output;
+  bool Interesting;
+};
+
+class IndexConsumer;
+
+class PreprocessorHook : public PPCallbacks {
+  IndexConsumer *Indexer;
+
+public:
+  PreprocessorHook(IndexConsumer *C) : Indexer(C) {}
+
+  virtual void MacroDefined(const Token &Tok,
+                            const MacroDirective *Md) override;
+
+  virtual void MacroExpands(const Token &Tok, const MacroDefinition &Md,
+                            SourceRange Range, const MacroArgs *Ma) override;
+#if CLANG_VERSION_MAJOR >= 5
+  virtual void MacroUndefined(const Token &tok, const MacroDefinition &md,
+                              const MacroDirective *Undef) override;
+#else
+  virtual void MacroUndefined(const Token &Tok,
+                              const MacroDefinition &Md) override;
+#endif
+  virtual void Defined(const Token &Tok, const MacroDefinition &Md,
+                       SourceRange Range) override;
+  virtual void Ifdef(SourceLocation Loc, const Token &Tok,
+                     const MacroDefinition &Md) override;
+  virtual void Ifndef(SourceLocation Loc, const Token &Tok,
+                      const MacroDefinition &Md) override;
+};
+
+class IndexConsumer : public ASTConsumer,
+                      public RecursiveASTVisitor<IndexConsumer>,
+                      public DiagnosticConsumer {
+private:
+  CompilerInstance &CI;
+  SourceManager &SM;
+  std::map<FileID, std::unique_ptr<FileInfo>> FileMap;
+  MangleContext *CurMangleContext;
+  ASTContext *AstContext;
+
+  typedef RecursiveASTVisitor<IndexConsumer> Super;
+
+  // Tracks the set of declarations that the current expression/statement is
+  // nested inside of.
+  struct AutoSetContext {
+    AutoSetContext(IndexConsumer *Self, NamedDecl *Context)
+        : Self(Self), Prev(Self->CurDeclContext), Decl(Context) {
+      Self->CurDeclContext = this;
+    }
+
+    ~AutoSetContext() { Self->CurDeclContext = Prev; }
+
+    IndexConsumer *Self;
+    AutoSetContext *Prev;
+    NamedDecl *Decl;
+  };
+  AutoSetContext *CurDeclContext;
+
+  FileInfo *getFileInfo(SourceLocation Loc) {
+    FileID Id = SM.getFileID(Loc);
+
+    std::map<FileID, std::unique_ptr<FileInfo>>::iterator It;
+    It = FileMap.find(Id);
+    if (It == FileMap.end()) {
+      // We haven't seen this file before. We need to make the FileInfo
+      // structure information ourselves
+      std::string Filename = SM.getFilename(Loc);
+      std::string Absolute = getAbsolutePath(Filename);
+      if (Absolute.empty()) {
+        Absolute = Filename;
+      }
+      std::unique_ptr<FileInfo> Info = llvm::make_unique<FileInfo>(Absolute);
+      It = FileMap.insert(std::make_pair(Id, std::move(Info))).first;
+    }
+    return It->second.get();
+  }
+
+  // Helpers for processing declarations
+  // Should we ignore this location?
+  bool isInterestingLocation(SourceLocation Loc) {
+    if (Loc.isInvalid()) {
+      return false;
+    }
+
+    return getFileInfo(Loc)->Interesting;
+  }
+
+  std::string locationToString(SourceLocation Loc, size_t Length = 0) {
+    std::pair<FileID, unsigned> Pair = SM.getDecomposedLoc(Loc);
+
+    bool IsInvalid;
+    unsigned Line = SM.getLineNumber(Pair.first, Pair.second, &IsInvalid);
+    if (IsInvalid) {
+      return "";
+    }
+    unsigned Column = SM.getColumnNumber(Pair.first, Pair.second, &IsInvalid);
+    if (IsInvalid) {
+      return "";
+    }
+
+    if (Length) {
+      return stringFormat("%05d:%d-%d", Line, Column - 1, Column - 1 + Length);
+    } else {
+      return stringFormat("%05d:%d", Line, Column - 1);
+    }
+  }
+
+  std::string lineRangeToString(SourceRange Range) {
+    std::pair<FileID, unsigned> Begin = SM.getDecomposedLoc(Range.getBegin());
+    std::pair<FileID, unsigned> End = SM.getDecomposedLoc(Range.getEnd());
+
+    bool IsInvalid;
+    unsigned Line1 = SM.getLineNumber(Begin.first, Begin.second, &IsInvalid);
+    if (IsInvalid) {
+      return "";
+    }
+    unsigned Line2 = SM.getLineNumber(End.first, End.second, &IsInvalid);
+    if (IsInvalid) {
+      return "";
+    }
+
+    return stringFormat("%d-%d", Line1, Line2);
+  }
+
+  // Returns the qualified name of `d` without considering template parameters.
+  std::string getQualifiedName(const NamedDecl *D) {
+    const DeclContext *Ctx = D->getDeclContext();
+    if (Ctx->isFunctionOrMethod()) {
+      return D->getQualifiedNameAsString();
+    }
+
+    std::vector<const DeclContext *> Contexts;
+
+    // Collect contexts.
+    while (Ctx && isa<NamedDecl>(Ctx)) {
+      Contexts.push_back(Ctx);
+      Ctx = Ctx->getParent();
+    }
+
+    std::string Result;
+
+    std::reverse(Contexts.begin(), Contexts.end());
+
+    for (const DeclContext *DC : Contexts) {
+      if (const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
+        Result += Spec->getNameAsString();
+
+        if (Spec->getSpecializationKind() == TSK_ExplicitSpecialization) {
+          std::string Backing;
+          llvm::raw_string_ostream Stream(Backing);
+          const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
+#if CLANG_VERSION_MAJOR > 3 ||                                                 \
+    (CLANG_VERSION_MAJOR == 3 && CLANG_VERSION_MINOR >= 9)
+          TemplateSpecializationType::PrintTemplateArgumentList(
+              Stream, TemplateArgs.asArray(), PrintingPolicy(CI.getLangOpts()));
+#else
+          TemplateSpecializationType::PrintTemplateArgumentList(
+              stream, templateArgs.data(), templateArgs.size(),
+              PrintingPolicy(CI.getLangOpts()));
+#endif
+          Result += Stream.str();
+        }
+      } else if (const auto *Nd = dyn_cast<NamespaceDecl>(DC)) {
+        if (Nd->isAnonymousNamespace() || Nd->isInline()) {
+          continue;
+        }
+        Result += Nd->getNameAsString();
+      } else if (const auto *Rd = dyn_cast<RecordDecl>(DC)) {
+        if (!Rd->getIdentifier()) {
+          Result += "(anonymous)";
+        } else {
+          Result += Rd->getNameAsString();
+        }
+      } else if (const auto *Fd = dyn_cast<FunctionDecl>(DC)) {
+        Result += Fd->getNameAsString();
+      } else if (const auto *Ed = dyn_cast<EnumDecl>(DC)) {
+        // C++ [dcl.enum]p10: Each enum-name and each unscoped
+        // enumerator is declared in the scope that immediately contains
+        // the enum-specifier. Each scoped enumerator is declared in the
+        // scope of the enumeration.
+        if (Ed->isScoped() || Ed->getIdentifier())
+          Result += Ed->getNameAsString();
+        else
+          continue;
+      } else {
+        Result += cast<NamedDecl>(DC)->getNameAsString();
+      }
+      Result += "::";
+    }
+
+    if (D->getDeclName())
+      Result += D->getNameAsString();
+    else
+      Result += "(anonymous)";
+
+    return Result;
+  }
+
+  std::string mangleLocation(SourceLocation Loc,
+                             std::string Backup = std::string()) {
+    FileInfo *F = getFileInfo(Loc);
+    std::string Filename = F->Realname;
+    if (Filename.length() == 0 && Backup.length() != 0) {
+      return Backup;
+    }
+    return hash(Filename + std::string("@") + locationToString(Loc));
+  }
+
+  std::string mangleQualifiedName(std::string Name) {
+    std::replace(Name.begin(), Name.end(), ' ', '_');
+    return Name;
+  }
+
+  std::string getMangledName(clang::MangleContext *Ctx,
+                             const clang::NamedDecl *Decl) {
+    if (isa<FunctionDecl>(Decl) || isa<VarDecl>(Decl)) {
+      const DeclContext *DC = Decl->getDeclContext();
+      if (isa<TranslationUnitDecl>(DC) || isa<NamespaceDecl>(DC) ||
+          isa<LinkageSpecDecl>(DC) ||
+          // isa<ExternCContextDecl>(DC) ||
+          isa<TagDecl>(DC)) {
+        llvm::SmallVector<char, 512> Output;
+        llvm::raw_svector_ostream Out(Output);
+        if (const CXXConstructorDecl *D = dyn_cast<CXXConstructorDecl>(Decl)) {
+          Ctx->mangleCXXCtor(D, CXXCtorType::Ctor_Complete, Out);
+        } else if (const CXXDestructorDecl *D =
+                       dyn_cast<CXXDestructorDecl>(Decl)) {
+          Ctx->mangleCXXDtor(D, CXXDtorType::Dtor_Complete, Out);
+        } else {
+          Ctx->mangleName(Decl, Out);
+        }
+        return Out.str().str();
+      } else {
+        return std::string("V_") + mangleLocation(Decl->getLocation()) +
+               std::string("_") + hash(Decl->getName());
+      }
+    } else if (isa<TagDecl>(Decl) || isa<TypedefNameDecl>(Decl)) {
+      if (!Decl->getIdentifier()) {
+        // Anonymous.
+        return std::string("T_") + mangleLocation(Decl->getLocation());
+      }
+
+      return std::string("T_") + mangleQualifiedName(getQualifiedName(Decl));
+    } else if (isa<NamespaceDecl>(Decl) || isa<NamespaceAliasDecl>(Decl)) {
+      if (!Decl->getIdentifier()) {
+        // Anonymous.
+        return std::string("NS_") + mangleLocation(Decl->getLocation());
+      }
+
+      return std::string("NS_") + mangleQualifiedName(getQualifiedName(Decl));
+    } else if (const FieldDecl *D2 = dyn_cast<FieldDecl>(Decl)) {
+      const RecordDecl *Record = D2->getParent();
+      return std::string("F_<") + getMangledName(Ctx, Record) + ">_" +
+             toString(D2->getFieldIndex());
+    } else if (const EnumConstantDecl *D2 = dyn_cast<EnumConstantDecl>(Decl)) {
+      const DeclContext *DC = Decl->getDeclContext();
+      if (const NamedDecl *Named = dyn_cast<NamedDecl>(DC)) {
+        return std::string("E_<") + getMangledName(Ctx, Named) + ">_" +
+               D2->getNameAsString();
+      }
+    }
+
+    assert(false);
+    return std::string("");
+  }
+
+  void debugLocation(SourceLocation Loc) {
+    std::string S = locationToString(Loc);
+    StringRef Filename = SM.getFilename(Loc);
+    printf("--> %s %s\n", std::string(Filename).c_str(), S.c_str());
+  }
+
+  void debugRange(SourceRange Range) {
+    printf("Range\n");
+    debugLocation(Range.getBegin());
+    debugLocation(Range.getEnd());
+  }
+
+public:
+  IndexConsumer(CompilerInstance &CI)
+      : CI(CI), SM(CI.getSourceManager()), CurMangleContext(nullptr),
+        AstContext(nullptr), CurDeclContext(nullptr), TemplateStack(nullptr) {
+    CI.getPreprocessor().addPPCallbacks(