From 2b0bd0bf0b90987b8607b57cb44af86e30d45719 Mon Sep 17 00:00:00 2001
From: Brendan Dahl <bdahl@mozilla.com>
Date: Tue, 13 Apr 2021 15:55:13 +0000
Subject: [PATCH] Bug 1704661 - Update pdf.js to version 2.9.44 r=calixte

Differential Revision: https://phabricator.services.mozilla.com/D111747
---
 .../locales/en-US/pdfviewer/chrome.properties |    1 +
 .../locales/en-US/pdfviewer/viewer.properties |    3 +
 toolkit/components/pdfjs/README.mozilla       |    4 +-
 toolkit/components/pdfjs/content/build/pdf.js |  184 ++-
 .../pdfjs/content/build/pdf.scripting.js      |    4 +-
 .../pdfjs/content/build/pdf.worker.js         | 1462 +++++++++++++----
 .../components/pdfjs/content/web/viewer.css   |  181 +-
 .../components/pdfjs/content/web/viewer.js    |  502 ++++--
 toolkit/components/pdfjs/moz.yaml             |    2 +-
 9 files changed, 1720 insertions(+), 623 deletions(-)

diff --git a/browser/locales/en-US/pdfviewer/chrome.properties b/browser/locales/en-US/pdfviewer/chrome.properties
index e42ac790caa8a..a8284958a2f6f 100644
--- a/browser/locales/en-US/pdfviewer/chrome.properties
+++ b/browser/locales/en-US/pdfviewer/chrome.properties
@@ -15,5 +15,6 @@
 # Chrome notification bar messages and buttons
 unsupported_feature=This PDF document might not be displayed correctly.
 unsupported_feature_forms=This PDF document contains forms. The filling of form fields is not supported.
+unsupported_feature_signatures=This PDF document contains digital signatures. Validation of signatures is not supported.
 open_with_different_viewer=Open With Different Viewer
 open_with_different_viewer.accessKey=o
diff --git a/browser/locales/en-US/pdfviewer/viewer.properties b/browser/locales/en-US/pdfviewer/viewer.properties
index 5fe094b769b28..1a7b908ebe88d 100644
--- a/browser/locales/en-US/pdfviewer/viewer.properties
+++ b/browser/locales/en-US/pdfviewer/viewer.properties
@@ -246,3 +246,6 @@ password_cancel=Cancel
 printing_not_supported=Warning: Printing is not fully supported by this browser.
 printing_not_ready=Warning: The PDF is not fully loaded for printing.
 web_fonts_disabled=Web fonts are disabled: unable to use embedded PDF fonts.
+# LOCALIZATION NOTE (unsupported_feature_signatures): Should contain the same
+# exact string as in the `chrome.properties` file.
+unsupported_feature_signatures=This PDF document contains digital signatures. Validation of signatures is not supported.
diff --git a/toolkit/components/pdfjs/README.mozilla b/toolkit/components/pdfjs/README.mozilla
index 9a8badd0e2dcc..d88e4c8ccc13a 100644
--- a/toolkit/components/pdfjs/README.mozilla
+++ b/toolkit/components/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.8.320
+Current extension version is: 2.9.44
 
-Taken from upstream commit: ca7f54682
+Taken from upstream commit: 6cf307000
diff --git a/toolkit/components/pdfjs/content/build/pdf.js b/toolkit/components/pdfjs/content/build/pdf.js
index 2beebc1d4a2bd..73c05f54f98a8 100644
--- a/toolkit/components/pdfjs/content/build/pdf.js
+++ b/toolkit/components/pdfjs/content/build/pdf.js
@@ -926,6 +926,7 @@ const UNSUPPORTED_FEATURES = {
   unknown: "unknown",
   forms: "forms",
   javaScript: "javaScript",
+  signatures: "signatures",
   smask: "smask",
   shadingPattern: "shadingPattern",
   font: "font",
@@ -1752,7 +1753,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
 
   return worker.messageHandler.sendWithPromise("GetDocRequest", {
     docId,
-    apiVersion: '2.8.320',
+    apiVersion: '2.9.44',
     source: {
       data: source.data,
       url: source.url,
@@ -1896,7 +1897,7 @@ class PDFDocumentProxy {
   }
 
   get annotationStorage() {
-    return (0, _util.shadow)(this, "annotationStorage", new _annotation_storage.AnnotationStorage());
+    return this._transport.annotationStorage;
   }
 
   get numPages() {
@@ -1991,8 +1992,8 @@ class PDFDocumentProxy {
     return this._transport.getStats();
   }
 
-  cleanup() {
-    return this._transport.startCleanup();
+  cleanup(keepLoadedFonts = false) {
+    return this._transport.startCleanup(keepLoadedFonts || this.isPureXfa);
   }
 
   destroy() {
@@ -2007,8 +2008,8 @@ class PDFDocumentProxy {
     return this._transport.loadingTask;
   }
 
-  saveDocument(annotationStorage) {
-    return this._transport.saveDocument(annotationStorage);
+  saveDocument() {
+    return this._transport.saveDocument();
   }
 
   getFieldObjects() {
@@ -2083,12 +2084,12 @@ class PDFPageProxy {
   getAnnotations({
     intent = null
   } = {}) {
-    if (!this.annotationsPromise || this.annotationsIntent !== intent) {
-      this.annotationsPromise = this._transport.getAnnotations(this._pageIndex, intent);
-      this.annotationsIntent = intent;
+    if (!this._annotationsPromise || this._annotationsIntent !== intent) {
+      this._annotationsPromise = this._transport.getAnnotations(this._pageIndex, intent);
+      this._annotationsIntent = intent;
     }
 
-    return this.annotationsPromise;
+    return this._annotationsPromise;
   }
 
   getJSActions() {
@@ -2109,7 +2110,7 @@ class PDFPageProxy {
     imageLayer = null,
     canvasFactory = null,
     background = null,
-    annotationStorage = null,
+    includeAnnotationStorage = false,
     optionalContentConfigPromise = null
   }) {
     if (this._stats) {
@@ -2142,6 +2143,7 @@ class PDFPageProxy {
     const webGLContext = new _webgl.WebGLContext({
       enable: enableWebGL
     });
+    const annotationStorage = includeAnnotationStorage ? this._transport.annotationStorage.serializable : null;
 
     if (!intentState.displayReadyCapability) {
       intentState.displayReadyCapability = (0, _util.createPromiseCapability)();
@@ -2159,16 +2161,12 @@ class PDFPageProxy {
         pageIndex: this._pageIndex,
         intent: renderingIntent,
         renderInteractiveForms: renderInteractiveForms === true,
-        annotationStorage: annotationStorage?.serializable || null
+        annotationStorage
       });
     }
 
     const complete = error => {
-      const i = intentState.renderTasks.indexOf(internalRenderTask);
-
-      if (i >= 0) {
-        intentState.renderTasks.splice(i, 1);
-      }
+      intentState.renderTasks.delete(internalRenderTask);
 
       if (this.cleanupAfterRender || renderingIntent === "print") {
         this.pendingCleanup = true;
@@ -2212,12 +2210,7 @@ class PDFPageProxy {
       useRequestAnimationFrame: renderingIntent !== "print",
       pdfBug: this._pdfBug
     });
-
-    if (!intentState.renderTasks) {
-      intentState.renderTasks = [];
-    }
-
-    intentState.renderTasks.push(internalRenderTask);
+    (intentState.renderTasks ||= new Set()).add(internalRenderTask);
     const renderTask = internalRenderTask.task;
     Promise.all([intentState.displayReadyCapability.promise, optionalContentConfigPromise]).then(([transparency, optionalContentConfig]) => {
       if (this.pendingCleanup) {
@@ -2242,11 +2235,7 @@ class PDFPageProxy {
     function operatorListChanged() {
       if (intentState.operatorList.lastChunk) {
         intentState.opListReadCapability.resolve(intentState.operatorList);
-        const i = intentState.renderTasks.indexOf(opListTask);
-
-        if (i >= 0) {
-          intentState.renderTasks.splice(i, 1);
-        }
+        intentState.renderTasks.delete(opListTask);
       }
     }
 
@@ -2266,8 +2255,7 @@ class PDFPageProxy {
       opListTask = Object.create(null);
       opListTask.operatorListChanged = operatorListChanged;
       intentState.opListReadCapability = (0, _util.createPromiseCapability)();
-      intentState.renderTasks = [];
-      intentState.renderTasks.push(opListTask);
+      (intentState.renderTasks ||= new Set()).add(opListTask);
       intentState.operatorList = {
         fnArray: [],
         argsArray: [],
@@ -2289,13 +2277,15 @@ class PDFPageProxy {
 
   streamTextContent({
     normalizeWhitespace = false,
-    disableCombineTextItems = false
+    disableCombineTextItems = false,
+    includeMarkedContent = false
   } = {}) {
     const TEXT_CONTENT_CHUNK_SIZE = 100;
     return this._transport.messageHandler.sendWithStream("GetTextContent", {
       pageIndex: this._pageIndex,
       normalizeWhitespace: normalizeWhitespace === true,
-      combineTextItems: disableCombineTextItems !== true
+      combineTextItems: disableCombineTextItems !== true,
+      includeMarkedContent: includeMarkedContent === true
     }, {
       highWaterMark: TEXT_CONTENT_CHUNK_SIZE,
 
@@ -2334,6 +2324,10 @@ class PDFPageProxy {
     });
   }
 
+  getStructTree() {
+    return this._structTreePromise ||= this._transport.getStructTree(this._pageIndex);
+  }
+
   _destroy() {
     this.destroyed = true;
     this._transport.pageCache[this._pageIndex] = null;
@@ -2357,9 +2351,10 @@ class PDFPageProxy {
     }
 
     this.objs.clear();
-    this.annotationsPromise = null;
+    this._annotationsPromise = null;
     this._jsActionsPromise = null;
     this._xfaPromise = null;
+    this._structTreePromise = null;
     this.pendingCleanup = false;
     return Promise.all(waitOn);
   }
@@ -2378,7 +2373,7 @@ class PDFPageProxy {
       renderTasks,
       operatorList
     } of this._intentStates.values()) {
-      if (renderTasks.length !== 0 || !operatorList.lastChunk) {
+      if (renderTasks.size > 0 || !operatorList.lastChunk) {
         return false;
       }
     }
@@ -2386,9 +2381,10 @@ class PDFPageProxy {
     this._intentStates.clear();
 
     this.objs.clear();
-    this.annotationsPromise = null;
+    this._annotationsPromise = null;
     this._jsActionsPromise = null;
     this._xfaPromise = null;
+    this._structTreePromise = null;
 
     if (resetStats && this._stats) {
       this._stats = new _display_utils.StatTimer();
@@ -2422,8 +2418,8 @@ class PDFPageProxy {
 
     intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
 
-    for (let i = 0; i < intentState.renderTasks.length; i++) {
-      intentState.renderTasks[i].operatorListChanged();
+    for (const internalRenderTask of intentState.renderTasks) {
+      internalRenderTask.operatorListChanged();
     }
 
     if (operatorListChunk.lastChunk) {
@@ -2469,8 +2465,8 @@ class PDFPageProxy {
         if (intentState.operatorList) {
           intentState.operatorList.lastChunk = true;
 
-          for (let i = 0; i < intentState.renderTasks.length; i++) {
-            intentState.renderTasks[i].operatorListChanged();
+          for (const internalRenderTask of intentState.renderTasks) {
+            internalRenderTask.operatorListChanged();
           }
 
           this._tryCleanup();
@@ -2501,7 +2497,7 @@ class PDFPageProxy {
     }
 
     if (!force) {
-      if (intentState.renderTasks.length !== 0) {
+      if (intentState.renderTasks.size > 0) {
         return;
       }
 
@@ -2959,8 +2955,8 @@ class WorkerTransport {
     this.setupMessageHandler();
   }
 
-  get loadingTaskSettled() {
-    return this.loadingTask._capability.settled;
+  get annotationStorage() {
+    return (0, _util.shadow)(this, "annotationStorage", new _annotation_storage.AnnotationStorage());
   }
 
   destroy() {
@@ -2983,18 +2979,13 @@ class WorkerTransport {
     });
     this.pageCache.length = 0;
     this.pagePromises.length = 0;
-    const terminated = this.messageHandler.sendWithPromise("Terminate", null);
-    waitOn.push(terminated);
 
-    if (this.loadingTaskSettled) {
-      const annotationStorageResetModified = this.loadingTask.promise.then(pdfDocument => {
-        if (pdfDocument.hasOwnProperty("annotationStorage")) {
-          pdfDocument.annotationStorage.resetModified();
-        }
-      }).catch(() => {});
-      waitOn.push(annotationStorageResetModified);
+    if (this.hasOwnProperty("annotationStorage")) {
+      this.annotationStorage.resetModified();
     }
 
+    const terminated = this.messageHandler.sendWithPromise("Terminate", null);
+    waitOn.push(terminated);
     Promise.all(waitOn).then(() => {
       this.commonObjs.clear();
       this.fontLoader.clear();
@@ -3388,15 +3379,13 @@ class WorkerTransport {
     });
   }
 
-  saveDocument(annotationStorage) {
+  saveDocument() {
     return this.messageHandler.sendWithPromise("SaveDocument", {
       numPages: this._numPages,
-      annotationStorage: annotationStorage?.serializable || null,
+      annotationStorage: this.annotationStorage.serializable,
       filename: this._fullReader?.filename ?? null
     }).finally(() => {
-      if (annotationStorage) {
-        annotationStorage.resetModified();
-      }
+      this.annotationStorage.resetModified();
     });
   }
 
@@ -3470,6 +3459,12 @@ class WorkerTransport {
     });
   }
 
+  getStructTree(pageIndex) {
+    return this.messageHandler.sendWithPromise("GetStructTree", {
+      pageIndex
+    });
+  }
+
   getOutline() {
     return this.messageHandler.sendWithPromise("GetOutline", null);
   }
@@ -3503,24 +3498,34 @@ class WorkerTransport {
     return this.messageHandler.sendWithPromise("GetStats", null);
   }
 
-  startCleanup() {
-    return this.messageHandler.sendWithPromise("Cleanup", null).then(() => {
-      for (let i = 0, ii = this.pageCache.length; i < ii; i++) {
-        const page = this.pageCache[i];
+  async startCleanup(keepLoadedFonts = false) {
+    await this.messageHandler.sendWithPromise("Cleanup", null);
 
-        if (page) {
-          const cleanupSuccessful = page.cleanup();
+    if (this.destroyed) {
+      return;
+    }
 
-          if (!cleanupSuccessful) {
-            throw new Error(`startCleanup: Page ${i + 1} is currently rendering.`);
-          }
-        }
+    for (let i = 0, ii = this.pageCache.length; i < ii; i++) {
+      const page = this.pageCache[i];
+
+      if (!page) {
+        continue;
       }
 
-      this.commonObjs.clear();
+      const cleanupSuccessful = page.cleanup();
+
+      if (!cleanupSuccessful) {
+        throw new Error(`startCleanup: Page ${i + 1} is currently rendering.`);
+      }
+    }
+
+    this.commonObjs.clear();
+
+    if (!keepLoadedFonts) {
       this.fontLoader.clear();
-      this._hasJSActionsPromise = null;
-    });
+    }
+
+    this._hasJSActionsPromise = null;
   }
 
   get loadingParams() {
@@ -3775,9 +3780,9 @@ const InternalRenderTask = function InternalRenderTaskClosure() {
   return InternalRenderTask;
 }();
 
-const version = '2.8.320';
+const version = '2.9.44';
 exports.version = version;
-const build = 'ca7f54682';
+const build = '6cf307000';
 exports.build = build;
 
 /***/ }),
@@ -4074,8 +4079,6 @@ Object.defineProperty(exports, "__esModule", ({
 }));
 exports.AnnotationStorage = void 0;
 
-var _display_utils = __w_pdfjs_require__(1);
-
 var _util = __w_pdfjs_require__(2);
 
 class AnnotationStorage {
@@ -4092,18 +4095,6 @@ class AnnotationStorage {
     return obj !== undefined ? obj : defaultValue;
   }
 
-  getOrCreateValue(key, defaultValue) {
-    (0, _display_utils.deprecated)("Use getValue instead.");
-
-    if (this._storage.has(key)) {
-      return this._storage.get(key);
-    }
-
-    this._storage.set(key, defaultValue);
-
-    return defaultValue;
-  }
-
   setValue(key, value) {
     const obj = this._storage.get(key);
 
@@ -10874,6 +10865,25 @@ const renderTextLayer = function renderTextLayerClosure() {
 
     _processItems(items, styleCache) {
       for (let i = 0, len = items.length; i < len; i++) {
+        if (items[i].str === undefined) {
+          if (items[i].type === "beginMarkedContentProps" || items[i].type === "beginMarkedContent") {
+            const parent = this._container;
+            this._container = document.createElement("span");
+
+            this._container.classList.add("markedContent");
+
+            if (items[i].id !== null) {
+              this._container.setAttribute("id", `${items[i].id}`);
+            }
+
+            parent.appendChild(this._container);
+          } else if (items[i].type === "endMarkedContent") {
+            this._container = this._container.parentNode;
+          }
+
+          continue;
+        }
+
         this._textContentItemsStr.push(items[i].str);
 
         appendText(this, items[i], styleCache, this._layoutTextCtx);
@@ -11454,8 +11464,8 @@ var _svg = __w_pdfjs_require__(21);
 
 var _xfa_layer = __w_pdfjs_require__(22);
 
-const pdfjsVersion = '2.8.320';
-const pdfjsBuild = 'ca7f54682';
+const pdfjsVersion = '2.9.44';
+const pdfjsBuild = '6cf307000';
 ;
 })();
 
diff --git a/toolkit/components/pdfjs/content/build/pdf.scripting.js b/toolkit/components/pdfjs/content/build/pdf.scripting.js
index 75b057ffbc99f..68a4eadf8bfc2 100644
--- a/toolkit/components/pdfjs/content/build/pdf.scripting.js
+++ b/toolkit/components/pdfjs/content/build/pdf.scripting.js
@@ -4768,8 +4768,8 @@ Object.defineProperty(exports, "initSandbox", ({
 
 var _initialization = __w_pdfjs_require__(1);
 
-const pdfjsVersion = '2.8.320';
-const pdfjsBuild = 'ca7f54682';
+const pdfjsVersion = '2.9.44';
+const pdfjsBuild = '6cf307000';
 })();
 
 /******/ 	return __webpack_exports__;
diff --git a/toolkit/components/pdfjs/content/build/pdf.worker.js b/toolkit/components/pdfjs/content/build/pdf.worker.js
index 9d2a9bf5f6b36..74168b95aa35b 100644
--- a/toolkit/components/pdfjs/content/build/pdf.worker.js
+++ b/toolkit/components/pdfjs/content/build/pdf.worker.js
@@ -50,13 +50,13 @@ var _primitives = __w_pdfjs_require__(5);
 
 var _pdf_manager = __w_pdfjs_require__(6);
 
-var _writer = __w_pdfjs_require__(48);
+var _writer = __w_pdfjs_require__(49);
 
 var _is_node = __w_pdfjs_require__(4);
 
-var _message_handler = __w_pdfjs_require__(69);
+var _message_handler = __w_pdfjs_require__(70);
 
-var _worker_stream = __w_pdfjs_require__(70);
+var _worker_stream = __w_pdfjs_require__(71);
 
 var _core_utils = __w_pdfjs_require__(8);
 
@@ -125,7 +125,7 @@ class WorkerMessageHandler {
     var WorkerTasks = [];
     const verbosity = (0, _util.getVerbosityLevel)();
     const apiVersion = docParams.apiVersion;
-    const workerVersion = '2.8.320';
+    const workerVersion = '2.9.44';
 
     if (apiVersion !== workerVersion) {
       throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
@@ -601,6 +601,7 @@ class WorkerMessageHandler {
           task,
           sink,
           normalizeWhitespace: data.normalizeWhitespace,
+          includeMarkedContent: data.includeMarkedContent,
           combineTextItems: data.combineTextItems
         }).then(function () {
           finishWorkerTask(task);
@@ -621,6 +622,14 @@ class WorkerMessageHandler {
         });
       });
     });
+    handler.on("GetStructTree", function wphGetStructTree(data) {
+      const pageIndex = data.pageIndex;
+      return pdfManager.getPage(pageIndex).then(function (page) {
+        return pdfManager.ensure(page, "getStructTree");
+      }).then(function (structTree) {
+        return structTree.serializable;
+      });
+    });
     handler.on("FontFallback", function (data) {
       return pdfManager.fontFallback(data.id, handler);
     });
@@ -1018,6 +1027,7 @@ const UNSUPPORTED_FEATURES = {
   unknown: "unknown",
   forms: "forms",
   javaScript: "javaScript",
+  signatures: "signatures",
   smask: "smask",
   shadingPattern: "shadingPattern",
   font: "font",
@@ -3209,17 +3219,19 @@ var _core_utils = __w_pdfjs_require__(8);
 
 var _stream = __w_pdfjs_require__(12);
 
-var _annotation = __w_pdfjs_require__(27);
+var _annotation = __w_pdfjs_require__(28);
 
 var _crypto = __w_pdfjs_require__(22);
 
 var _parser = __w_pdfjs_require__(11);
 
-var _operator_list = __w_pdfjs_require__(46);
+var _operator_list = __w_pdfjs_require__(47);
 
-var _evaluator = __w_pdfjs_require__(29);
+var _evaluator = __w_pdfjs_require__(30);
 
-var _factory = __w_pdfjs_require__(49);
+var _struct_tree = __w_pdfjs_require__(27);
+
+var _factory = __w_pdfjs_require__(50);
 
 const DEFAULT_USER_UNIT = 1.0;
 const LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
@@ -3262,6 +3274,10 @@ class Page {
         return `p${pageIndex}_${++idCounters.obj}`;
       }
 
+      static getPageObjId() {
+        return `page${ref.toString()}`;
+      }
+
     };
   }
 
@@ -3517,6 +3533,7 @@ class Page {
     handler,
     task,
     normalizeWhitespace,
+    includeMarkedContent,
     sink,
     combineTextItems
   }) {
@@ -3539,12 +3556,24 @@ class Page {
         task,
         resources: this.resources,
         normalizeWhitespace,
+        includeMarkedContent,
         combineTextItems,
         sink
       });
     });
   }
 
+  async getStructTree() {
+    const structTreeRoot = await this.pdfManager.ensureCatalog("structTreeRoot");
+    return this.pdfManager.ensure(this, "_parseStructTree", [structTreeRoot]);
+  }
+
+  _parseStructTree(structTreeRoot) {
+    const tree = new _struct_tree.StructTreePage(structTreeRoot, this.pageDict);
+    tree.parse();
+    return tree;
+  }
+
   getAnnotationsData(intent) {
     return this._parsedAnnotations.then(function (annotations) {
       const annotationsData = [];
@@ -3684,6 +3713,10 @@ class PDFDocument {
         (0, _util.unreachable)("Abstract method `createObjId` called.");
       }
 
+      static getPageObjId() {
+        (0, _util.unreachable)("Abstract method `getPageObjId` called.");
+      }
+
     };
   }
 
@@ -3917,7 +3950,8 @@ class PDFDocument {
     const formInfo = {
       hasFields: false,
       hasAcroForm: false,
-      hasXfa: false
+      hasXfa: false,
+      hasSignatures: false
     };
     const acroForm = this.catalog.acroForm;
 
@@ -3932,10 +3966,12 @@ class PDFDocument {
       const xfa = acroForm.get("XFA");
       formInfo.hasXfa = Array.isArray(xfa) && xfa.length > 0 || (0, _primitives.isStream)(xfa) && !xfa.isEmpty;
       const sigFlags = acroForm.get("SigFlags");
+      const hasSignatures = !!(sigFlags & 0x1);
 
-      const hasOnlyDocumentSignatures = !!(sigFlags & 0x1) && this._hasOnlyDocumentSignatures(fields);
+      const hasOnlyDocumentSignatures = hasSignatures && this._hasOnlyDocumentSignatures(fields);
 
       formInfo.hasAcroForm = hasFields && !hasOnlyDocumentSignatures;
+      formInfo.hasSignatures = hasSignatures;
     } catch (ex) {
       if (ex instanceof _core_utils.MissingDataException) {
         throw ex;
@@ -3971,7 +4007,8 @@ class PDFDocument {
       IsLinearized: !!this.linearization,
       IsAcroFormPresent: this.formInfo.hasAcroForm,
       IsXFAPresent: this.formInfo.hasXfa,
-      IsCollectionPresent: !!this.catalog.collection
+      IsCollectionPresent: !!this.catalog.collection,
+      IsSignaturesPresent: this.formInfo.hasSignatures
     };
     let infoDict;
 
@@ -4224,7 +4261,7 @@ exports.PDFDocument = PDFDocument;
 Object.defineProperty(exports, "__esModule", ({
   value: true
 }));
-exports.XRef = exports.ObjectLoader = exports.FileSpec = exports.Catalog = void 0;
+exports.XRef = exports.ObjectLoader = exports.NumberTree = exports.FileSpec = exports.Catalog = void 0;
 
 var _util = __w_pdfjs_require__(2);
 
@@ -4242,6 +4279,8 @@ var _image_utils = __w_pdfjs_require__(24);
 
 var _metadata_parser = __w_pdfjs_require__(25);
 
+var _struct_tree = __w_pdfjs_require__(27);
+
 function fetchDestination(dest) {
   return (0, _primitives.isDict)(dest) ? dest.get("D") : dest;
 }
@@ -4394,6 +4433,34 @@ class Catalog {
     return markInfo;
   }
 
+  get structTreeRoot() {
+    let structTree = null;
+
+    try {
+      structTree = this._readStructTreeRoot();
+    } catch (ex) {
+      if (ex instanceof _core_utils.MissingDataException) {
+        throw ex;
+      }
+
+      (0, _util.warn)("Unable read to structTreeRoot info.");
+    }
+
+    return (0, _util.shadow)(this, "structTreeRoot", structTree);
+  }
+
+  _readStructTreeRoot() {
+    const obj = this._catDict.get("StructTreeRoot");
+
+    if (!(0, _primitives.isDict)(obj)) {
+      return null;
+    }
+
+    const root = new _struct_tree.StructTreeRoot(obj);
+    root.init();
+    return root;
+  }
+
   get toplevelPagesDict() {
     const pagesObj = this._catDict.get("Pages");
 
@@ -6122,19 +6189,19 @@ var XRef = function XRefClosure() {
     },
     readXRef: function XRef_readXRef(recoveryMode) {
       var stream = this.stream;
-      const startXRefParsedCache = Object.create(null);
+      const startXRefParsedCache = new Set();
 
       try {
         while (this.startXRefQueue.length) {
           var startXRef = this.startXRefQueue[0];
 
-          if (startXRefParsedCache[startXRef]) {
+          if (startXRefParsedCache.has(startXRef)) {
             (0, _util.warn)("readXRef - skipping XRef table since it was already parsed.");
             this.startXRefQueue.shift();
             continue;
           }
 
-          startXRefParsedCache[startXRef] = true;
+          startXRefParsedCache.add(startXRef);
           stream.pos = startXRef + stream.start;
           const parser = new _parser.Parser({
             lexer: new _parser.Lexer(stream),
@@ -6572,6 +6639,8 @@ class NumberTree extends NameOrNumberTree {
 
 }
 
+exports.NumberTree = NumberTree;
+
 var FileSpec = function FileSpecClosure() {
   function FileSpec(root, xref) {
     if (!root || !(0, _primitives.isDict)(root)) {
@@ -20325,6 +20394,373 @@ exports.SimpleXMLParser = SimpleXMLParser;
 
 
 
+Object.defineProperty(exports, "__esModule", ({
+  value: true
+}));
+exports.StructTreeRoot = exports.StructTreePage = void 0;
+
+var _primitives = __w_pdfjs_require__(5);
+
+var _util = __w_pdfjs_require__(2);
+
+var _obj = __w_pdfjs_require__(10);
+
+const MAX_DEPTH = 40;
+const StructElementType = {
+  PAGE_CONTENT: "PAGE_CONTENT",
+  STREAM_CONTENT: "STREAM_CONTENT",
+  OBJECT: "OBJECT",
+  ELEMENT: "ELEMENT"
+};
+
+class StructTreeRoot {
+  constructor(rootDict) {
+    this.dict = rootDict;
+    this.roleMap = new Map();
+  }
+
+  init() {
+    this.readRoleMap();
+  }
+
+  readRoleMap() {
+    const roleMapDict = this.dict.get("RoleMap");
+
+    if (!(0, _primitives.isDict)(roleMapDict)) {
+      return;
+    }
+
+    roleMapDict.forEach((key, value) => {
+      if (!(0, _primitives.isName)(value)) {
+        return;
+      }
+
+      this.roleMap.set(key, value.name);
+    });
+  }
+
+}
+
+exports.StructTreeRoot = StructTreeRoot;
+
+class StructElementNode {
+  constructor(tree, dict) {
+    this.tree = tree;
+    this.dict = dict;
+    this.kids = [];
+    this.parseKids();
+  }
+
+  get role() {
+    const nameObj = this.dict.get("S");
+    const name = (0, _primitives.isName)(nameObj) ? nameObj.name : "";
+    const {
+      root
+    } = this.tree;
+
+    if (root.roleMap.has(name)) {
+      return root.roleMap.get(name);
+    }
+
+    return name;
+  }
+
+  parseKids() {
+    let pageObjId = null;
+    const objRef = this.dict.getRaw("Pg");
+
+    if ((0, _primitives.isRef)(objRef)) {
+      pageObjId = objRef.toString();
+    }
+
+    const kids = this.dict.get("K");
+
+    if (Array.isArray(kids)) {
+      for (const kid of kids) {
+        const element = this.parseKid(pageObjId, kid);
+
+        if (element) {
+          this.kids.push(element);
+        }
+      }
+    } else {
+      const element = this.parseKid(pageObjId, kids);
+
+      if (element) {
+        this.kids.push(element);
+      }
+    }
+  }
+
+  parseKid(pageObjId, kid) {
+    if (Number.isInteger(kid)) {
+      if (this.tree.pageDict.objId !== pageObjId) {
+        return null;
+      }
+
+      return new StructElement({
+        type: StructElementType.PAGE_CONTENT,
+        mcid: kid,
+        pageObjId
+      });
+    }
+
+    let kidDict = null;
+
+    if ((0, _primitives.isRef)(kid)) {
+      kidDict = this.dict.xref.fetch(kid);
+    } else if ((0, _primitives.isDict)(kid)) {
+      kidDict = kid;
+    }
+
+    if (!kidDict) {
+      return null;
+    }
+
+    const pageRef = kidDict.getRaw("Pg");
+
+    if ((0, _primitives.isRef)(pageRef)) {
+      pageObjId = pageRef.toString();
+    }
+
+    const type = (0, _primitives.isName)(kidDict.get("Type")) ? kidDict.get("Type").name : null;
+
+    if (type === "MCR") {
+      if (this.tree.pageDict.objId !== pageObjId) {
+        return null;
+      }
+
+      return new StructElement({
+        type: StructElementType.STREAM_CONTENT,
+        refObjId: (0, _primitives.isRef)(kidDict.getRaw("Stm")) ? kidDict.getRaw("Stm").toString() : null,
+        pageObjId,
+        mcid: kidDict.get("MCID")
+      });
+    }
+
+    if (type === "OBJR") {
+      if (this.tree.pageDict.objId !== pageObjId) {
+        return null;
+      }
+
+      return new StructElement({
+        type: StructElementType.OBJECT,
+        refObjId: (0, _primitives.isRef)(kidDict.getRaw("Obj")) ? kidDict.getRaw("Obj").toString() : null,
+        pageObjId
+      });
+    }
+
+    return new StructElement({
+      type: StructElementType.ELEMENT,
+      dict: kidDict
+    });
+  }
+
+}
+
+class StructElement {
+  constructor({
+    type,
+    dict = null,
+    mcid = null,
+    pageObjId = null,
+    refObjId = null
+  }) {
+    this.type = type;
+    this.dict = dict;
+    this.mcid = mcid;
+    this.pageObjId = pageObjId;
+    this.refObjId = refObjId;
+    this.parentNode = null;
+  }
+
+}
+
+class StructTreePage {
+  constructor(structTreeRoot, pageDict) {
+    this.root = structTreeRoot;
+    this.rootDict = structTreeRoot ? structTreeRoot.dict : null;
+    this.pageDict = pageDict;
+    this.nodes = [];
+  }
+
+  parse() {
+    if (!this.root || !this.rootDict) {
+      return;
+    }
+
+    const parentTree = this.rootDict.get("ParentTree");
+
+    if (!parentTree) {
+      return;
+    }
+
+    const id = this.pageDict.get("StructParents");
+
+    if (!Number.isInteger(id)) {
+      return;
+    }
+
+    const numberTree = new _obj.NumberTree(parentTree, this.rootDict.xref);
+    const parentArray = numberTree.get(id);
+
+    if (!Array.isArray(parentArray)) {
+      return;
+    }
+
+    const map = new Map();
+
+    for (const ref of parentArray) {
+      if ((0, _primitives.isRef)(ref)) {
+        this.addNode(this.rootDict.xref.fetch(ref), map);
+      }
+    }
+  }
+
+  addNode(dict, map, level = 0) {
+    if (level > MAX_DEPTH) {
+      (0, _util.warn)("StructTree MAX_DEPTH reached.");
+      return null;
+    }
+
+    if (map.has(dict)) {
+      return map.get(dict);
+    }
+
+    const element = new StructElementNode(this, dict);
+    map.set(dict, element);
+    const parent = dict.get("P");
+
+    if (!parent || (0, _primitives.isName)(parent.get("Type"), "StructTreeRoot")) {
+      if (!this.addTopLevelNode(dict, element)) {
+        map.delete(dict);
+      }
+
+      return element;
+    }
+
+    const parentNode = this.addNode(parent, map, level + 1);
+
+    if (!parentNode) {
+      return element;
+    }
+
+    let save = false;
+
+    for (const kid of parentNode.kids) {
+      if (kid.type === StructElementType.ELEMENT && kid.dict === dict) {
+        kid.parentNode = element;
+        save = true;
+      }
+    }
+
+    if (!save) {
+      map.delete(dict);
+    }
+
+    return element;
+  }
+
+  addTopLevelNode(dict, element) {
+    const obj = this.rootDict.get("K");
+
+    if (!obj) {
+      return false;
+    }
+
+    if ((0, _primitives.isDict)(obj)) {
+      if (obj.objId !== dict.objId) {
+        return false;
+      }
+
+      this.nodes[0] = element;
+      return true;
+    }
+
+    if (!Array.isArray(obj)) {
+      return true;
+    }
+
+    let save = false;
+
+    for (let i = 0; i < obj.length; i++) {
+      const kidRef = obj[i];
+
+      if (kidRef && kidRef.toString() === dict.objId) {
+        this.nodes[i] = element;
+        save = true;
+      }
+    }
+
+    return save;
+  }
+
+  get serializable() {
+    function nodeToSerializable(node, parent, level = 0) {
+      if (level > MAX_DEPTH) {
+        (0, _util.warn)("StructTree too deep to be fully serialized.");
+        return;
+      }
+
+      const obj = Object.create(null);
+      obj.role = node.role;
+      obj.children = [];
+      parent.children.push(obj);
+      const alt = node.dict.get("Alt");
+
+      if ((0, _util.isString)(alt)) {
+        obj.alt = (0, _util.stringToPDFString)(alt);
+      }
+
+      for (const kid of node.kids) {
+        const kidElement = kid.type === StructElementType.ELEMENT ? kid.parentNode : null;
+
+        if (kidElement) {
+          nodeToSerializable(kidElement, obj, level + 1);
+          continue;
+        } else if (kid.type === StructElementType.PAGE_CONTENT || kid.type === StructElementType.STREAM_CONTENT) {
+          obj.children.push({
+            type: "content",
+            id: `page${kid.pageObjId}_mcid${kid.mcid}`
+          });
+        } else if (kid.type === StructElementType.OBJECT) {
+          obj.children.push({
+            type: "object",
+            id: kid.refObjId
+          });
+        }
+      }
+    }
+
+    const root = Object.create(null);
+    root.children = [];
+    root.role = "Root";
+
+    for (const child of this.nodes) {
+      if (!child) {
+        continue;
+      }
+
+      nodeToSerializable(child, root);
+    }
+
+    if (root.children.length === 0) {
+      return null;
+    }
+
+    return root;
+  }
+
+}
+
+exports.StructTreePage = StructTreePage;
+
+/***/ }),
+/* 28 */
+/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
+
+
+
 Object.defineProperty(exports, "__esModule", ({
   value: true
 }));
@@ -20337,17 +20773,17 @@ var _obj = __w_pdfjs_require__(10);
 
 var _core_utils = __w_pdfjs_require__(8);
 
-var _default_appearance = __w_pdfjs_require__(28);
+var _default_appearance = __w_pdfjs_require__(29);
 
 var _primitives = __w_pdfjs_require__(5);
 
 var _colorspace = __w_pdfjs_require__(23);
 
-var _operator_list = __w_pdfjs_require__(46);
+var _operator_list = __w_pdfjs_require__(47);
 
 var _stream = __w_pdfjs_require__(12);
 
-var _writer = __w_pdfjs_require__(48);
+var _writer = __w_pdfjs_require__(49);
 
 class AnnotationFactory {
   static create(xref, ref, pdfManager, idFactory, collectFields) {
@@ -20400,6 +20836,9 @@ class AnnotationFactory {
 
           case "Ch":
             return new ChoiceWidgetAnnotation(parameters);
+
+          case "Sig":
+            return new SignatureWidgetAnnotation(parameters);
         }
 
         (0, _util.warn)(`Unimplemented widget field type "${fieldType}", ` + "falling back to base field type.");
@@ -21168,12 +21607,6 @@ class WidgetAnnotation extends Annotation {
 
     data.readOnly = this.hasFieldFlag(_util.AnnotationFieldFlag.READONLY);
     data.hidden = this._hasFlag(data.annotationFlags, _util.AnnotationFlag.HIDDEN);
-
-    if (data.fieldType === "Sig") {
-      data.fieldValue = null;
-      this.setFlags(_util.AnnotationFlag.HIDDEN);
-      data.hidden = true;
-    }
   }
 
   _decodeFormValue(formValue) {
@@ -21193,7 +21626,7 @@ class WidgetAnnotation extends Annotation {
   }
 
   getOperatorList(evaluator, task, renderForms, annotationStorage) {
-    if (renderForms) {
+    if (renderForms && !(this instanceof SignatureWidgetAnnotation)) {
       return Promise.resolve(new _operator_list.OperatorList());
     }
 
@@ -21381,7 +21814,7 @@ class WidgetAnnotation extends Annotation {
       fontName,
       fontSize
     } = this.data.defaultAppearanceData;
-    await evaluator.handleSetFont(this._fieldResources.mergedResources, [fontName, fontSize], null, operatorList, task, initialState, null);
+    await evaluator.handleSetFont(this._fieldResources.mergedResources, [fontName && _primitives.Name.get(fontName), fontSize], null, operatorList, task, initialState, null);
     return initialState.font;
   }
 
@@ -21450,9 +21883,9 @@ class WidgetAnnotation extends Annotation {
       appearanceResources,
       acroFormResources
     } = this._fieldResources;
-    const fontNameStr = this.data.defaultAppearanceData && this.data.defaultAppearanceData.fontName.name;
+    const fontName = this.data.defaultAppearanceData && this.data.defaultAppearanceData.fontName;
 
-    if (!fontNameStr) {
+    if (!fontName) {
       return localResources || _primitives.Dict.empty;
     }
 
@@ -21460,7 +21893,7 @@ class WidgetAnnotation extends Annotation {
       if (resources instanceof _primitives.Dict) {
         const localFont = resources.get("Font");
 
-        if (localFont instanceof _primitives.Dict && localFont.has(fontNameStr)) {
+        if (localFont instanceof _primitives.Dict && localFont.has(fontName)) {
           return resources;
         }
       }
@@ -21469,9 +21902,9 @@ class WidgetAnnotation extends Annotation {
     if (acroFormResources instanceof _primitives.Dict) {
       const acroFormFont = acroFormResources.get("Font");
 
-      if (acroFormFont instanceof _primitives.Dict && acroFormFont.has(fontNameStr)) {
+      if (acroFormFont instanceof _primitives.Dict && acroFormFont.has(fontName)) {
         const subFontDict = new _primitives.Dict(xref);
-        subFontDict.set(fontNameStr, acroFormFont.getRaw(fontNameStr));
+        subFontDict.set(fontName, acroFormFont.getRaw(fontName));
         const subResourcesDict = new _primitives.Dict(xref);
         subResourcesDict.set("Font", subFontDict);
         return _primitives.Dict.merge({
@@ -21486,14 +21919,6 @@ class WidgetAnnotation extends Annotation {
   }
 
   getFieldObject() {
-    if (this.data.fieldType === "Sig") {
-      return {
-        id: this.data.id,
-        value: null,
-        type: "signature"
-      };
-    }
-
     return null;
   }
 
@@ -22030,6 +22455,22 @@ class ChoiceWidgetAnnotation extends WidgetAnnotation {
 
 }
 
+class SignatureWidgetAnnotation extends WidgetAnnotation {
+  constructor(params) {
+    super(params);
+    this.data.fieldValue = null;
+  }
+
+  getFieldObject() {
+    return {
+      id: this.data.id,
+      value: null,
+      type: "signature"
+    };
+  }
+
+}
+
 class TextAnnotation extends MarkupAnnotation {
   constructor(parameters) {
     const DEFAULT_ICON_SIZE = 22;
@@ -22476,7 +22917,7 @@ class FileAttachmentAnnotation extends MarkupAnnotation {
 }
 
 /***/ }),
-/* 28 */
+/* 29 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -22487,15 +22928,15 @@ Object.defineProperty(exports, "__esModule", ({
 exports.createDefaultAppearance = createDefaultAppearance;
 exports.parseDefaultAppearance = parseDefaultAppearance;
 
-var _primitives = __w_pdfjs_require__(5);
-
 var _util = __w_pdfjs_require__(2);
 
 var _colorspace = __w_pdfjs_require__(23);
 
 var _core_utils = __w_pdfjs_require__(8);
 
-var _evaluator = __w_pdfjs_require__(29);
+var _evaluator = __w_pdfjs_require__(30);
+
+var _primitives = __w_pdfjs_require__(5);
 
 var _stream = __w_pdfjs_require__(12);
 
@@ -22511,8 +22952,8 @@ class DefaultAppearanceEvaluator extends _evaluator.EvaluatorPreprocessor {
     };
     const result = {
       fontSize: 0,
-      fontName: _primitives.Name.get(""),
-      fontColor: new Uint8ClampedArray([0, 0, 0])
+      fontName: "",
+      fontColor: new Uint8ClampedArray(3)
     };
 
     try {
@@ -22536,8 +22977,8 @@ class DefaultAppearanceEvaluator extends _evaluator.EvaluatorPreprocessor {
           case _util.OPS.setFont:
             const [fontName, fontSize] = args;
 
-            if ((0, _primitives.isName)(fontName)) {
-              result.fontName = fontName;
+            if (fontName instanceof _primitives.Name) {
+              result.fontName = fontName.name;
             }
 
             if (typeof fontSize === "number" && fontSize > 0) {
@@ -22588,11 +23029,11 @@ function createDefaultAppearance({
     colorCmd = Array.from(fontColor).map(c => (c / 255).toFixed(2)).join(" ") + " rg";
   }
 
-  return `/${(0, _core_utils.escapePDFName)(fontName.name)} ${fontSize} Tf ${colorCmd}`;
+  return `/${(0, _core_utils.escapePDFName)(fontName)} ${fontSize} Tf ${colorCmd}`;
 }
 
 /***/ }),
-/* 29 */
+/* 30 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -22604,43 +23045,43 @@ exports.PartialEvaluator = exports.EvaluatorPreprocessor = void 0;
 
 var _util = __w_pdfjs_require__(2);
 
-var _cmap = __w_pdfjs_require__(30);
+var _cmap = __w_pdfjs_require__(31);
 
 var _primitives = __w_pdfjs_require__(5);
 
 var _stream = __w_pdfjs_require__(12);
 
-var _fonts = __w_pdfjs_require__(31);
+var _fonts = __w_pdfjs_require__(32);
 
-var _encodings = __w_pdfjs_require__(34);
+var _encodings = __w_pdfjs_require__(35);
 
-var _unicode = __w_pdfjs_require__(37);
+var _unicode = __w_pdfjs_require__(38);
 
-var _standard_fonts = __w_pdfjs_require__(36);
+var _standard_fonts = __w_pdfjs_require__(37);
 
-var _pattern = __w_pdfjs_require__(40);
+var _pattern = __w_pdfjs_require__(41);
 
-var _function = __w_pdfjs_require__(41);
+var _function = __w_pdfjs_require__(42);
 
 var _parser = __w_pdfjs_require__(11);
 
 var _image_utils = __w_pdfjs_require__(24);
 
-var _bidi = __w_pdfjs_require__(43);
+var _bidi = __w_pdfjs_require__(44);
 
 var _colorspace = __w_pdfjs_require__(23);
 
-var _glyphlist = __w_pdfjs_require__(35);
+var _glyphlist = __w_pdfjs_require__(36);
 
 var _core_utils = __w_pdfjs_require__(8);
 
-var _metrics = __w_pdfjs_require__(44);
+var _metrics = __w_pdfjs_require__(45);
 
-var _murmurhash = __w_pdfjs_require__(45);
+var _murmurhash = __w_pdfjs_require__(46);
 
-var _operator_list = __w_pdfjs_require__(46);
+var _operator_list = __w_pdfjs_require__(47);
 
-var _image = __w_pdfjs_require__(47);
+var _image = __w_pdfjs_require__(48);
 
 const DefaultPartialEvaluatorOptions = Object.freeze({
   maxImageSize: -1,
@@ -23304,13 +23745,7 @@ class PartialEvaluator {
   }
 
   handleSetFont(resources, fontArgs, fontRef, operatorList, task, state, fallbackFontDict = null) {
-    var fontName;
-
-    if (fontArgs) {
-      fontArgs = fontArgs.slice();
-      fontName = fontArgs[0].name;
-    }
-
+    const fontName = fontArgs && fontArgs[0] instanceof _primitives.Name ? fontArgs[0].name : null;
     return this.loadFont(fontName, fontRef, resources, fallbackFontDict).then(translated => {
       if (!translated.font.isType3Font) {
         return translated;
@@ -24280,7 +24715,7 @@ class PartialEvaluator {
               return;
             }
 
-            args = [args[0].name];
+            args = [args[0].name, args[1] instanceof _primitives.Dict ? args[1].get("MCID") : null];
             break;
 
           case _util.OPS.beginMarkedContent:
@@ -24336,8 +24771,9 @@ class PartialEvaluator {
     stateManager = null,
     normalizeWhitespace = false,
     combineTextItems = false,
+    includeMarkedContent = false,
     sink,
-    seenStyles = Object.create(null)
+    seenStyles = new Set()
   }) {
     resources = resources || _primitives.Dict.empty;
     stateManager = stateManager || new StateManager(new TextState());
@@ -24379,11 +24815,12 @@ class PartialEvaluator {
         return textContentItem;
       }
 
-      var font = textState.font;
+      const font = textState.font,
+            loadedName = font.loadedName;
 
-      if (!(font.loadedName in seenStyles)) {
-        seenStyles[font.loadedName] = true;
-        textContent.styles[font.loadedName] = {
+      if (!seenStyles.has(loadedName)) {
+        seenStyles.add(loadedName);
+        textContent.styles[loadedName] = {
           fontFamily: font.fallbackName,
           ascent: font.ascent,
           descent: font.descent,
@@ -24391,7 +24828,7 @@ class PartialEvaluator {
         };
       }
 
-      textContentItem.fontName = font.loadedName;
+      textContentItem.fontName = loadedName;
       var tsm = [textState.fontSize * textState.textHScale, 0, 0, textState.fontSize, 0, textState.textRise];
 
       if (font.isType3Font && textState.fontSize <= 1 && !(0, _util.isArrayEqual)(textState.fontMatrix, _util.FONT_IDENTITY_MATRIX)) {
@@ -24867,6 +25304,7 @@ class PartialEvaluator {
                 stateManager: xObjStateManager,
                 normalizeWhitespace,
                 combineTextItems,
+                includeMarkedContent,
                 sink: sinkWrapper,
                 seenStyles
               }).then(function () {
@@ -24939,6 +25377,44 @@ class PartialEvaluator {
               throw reason;
             }));
             return;
+
+          case _util.OPS.beginMarkedContent:
+            if (includeMarkedContent) {
+              textContent.items.push({
+                type: "beginMarkedContent",
+                tag: (0, _primitives.isName)(args[0]) ? args[0].name : null
+              });
+            }
+
+            break;
+
+          case _util.OPS.beginMarkedContentProps:
+            if (includeMarkedContent) {
+              flushTextContentItem();
+              let mcid = null;
+
+              if ((0, _primitives.isDict)(args[1])) {
+                mcid = args[1].get("MCID");
+              }
+
+              textContent.items.push({
+                type: "beginMarkedContentProps",
+                id: Number.isInteger(mcid) ? `${self.idFactory.getPageObjId()}_mcid${mcid}` : null,
+                tag: (0, _primitives.isName)(args[0]) ? args[0].name : null
+              });
+            }
+
+            break;
+
+          case _util.OPS.endMarkedContent:
+            if (includeMarkedContent) {
+              flushTextContentItem();
+              textContent.items.push({
+                type: "endMarkedContent"
+              });
+            }
+
+            break;
         }
 
         if (textContent.items.length >= sink.desiredSize) {
@@ -26554,7 +27030,7 @@ class EvaluatorPreprocessor {
 exports.EvaluatorPreprocessor = EvaluatorPreprocessor;
 
 /***/ }),
-/* 30 */
+/* 31 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -27472,7 +27948,7 @@ var CMapFactory = function CMapFactoryClosure() {
 exports.CMapFactory = CMapFactory;
 
 /***/ }),
-/* 31 */
+/* 32 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -27485,25 +27961,25 @@ exports.ToUnicodeMap = exports.SEAC_ANALYSIS_ENABLED = exports.IdentityToUnicode
 
 var _util = __w_pdfjs_require__(2);
 
-var _cff_parser = __w_pdfjs_require__(32);
+var _cff_parser = __w_pdfjs_require__(33);
 
-var _glyphlist = __w_pdfjs_require__(35);
+var _glyphlist = __w_pdfjs_require__(36);
 
-var _encodings = __w_pdfjs_require__(34);
+var _encodings = __w_pdfjs_require__(35);
 
-var _standard_fonts = __w_pdfjs_require__(36);
+var _standard_fonts = __w_pdfjs_require__(37);
 
-var _unicode = __w_pdfjs_require__(37);
+var _unicode = __w_pdfjs_require__(38);
 
 var _core_utils = __w_pdfjs_require__(8);
 
-var _font_renderer = __w_pdfjs_require__(38);
+var _font_renderer = __w_pdfjs_require__(39);
 
-var _cmap = __w_pdfjs_require__(30);
+var _cmap = __w_pdfjs_require__(31);
 
 var _stream = __w_pdfjs_require__(12);
 
-var _type1_parser = __w_pdfjs_require__(39);
+var _type1_parser = __w_pdfjs_require__(40);
 
 const PRIVATE_USE_AREAS = [[0xe000, 0xf8ff], [0x100000, 0x10fffd]];
 var PDF_GLYPH_SPACE_UNITS = 1000;
@@ -28685,6 +29161,8 @@ var Font = function FontClosure() {
           numFonts,
           offsetTable
         } = readTrueTypeCollectionHeader(ttc);
+        const fontNameParts = fontName.split("+");
+        let fallbackData;
 
         for (let i = 0; i < numFonts; i++) {
           ttc.pos = (ttc.start || 0) + offsetTable[i];
@@ -28699,18 +29177,44 @@ var Font = function FontClosure() {
 
           for (let j = 0, jj = nameTable.length; j < jj; j++) {
             for (let k = 0, kk = nameTable[j].length; k < kk; k++) {
-              const nameEntry = nameTable[j][k];
+              const nameEntry = nameTable[j][k] && nameTable[j][k].replace(/\s/g, "");
+
+              if (!nameEntry) {
+                continue;
+              }
 
-              if (nameEntry && nameEntry.replace(/\s/g, "") === fontName) {
+              if (nameEntry === fontName) {
                 return {
                   header: potentialHeader,
                   tables: potentialTables
                 };
               }
+
+              if (fontNameParts.length < 2) {
+                continue;
+              }
+
+              for (const part of fontNameParts) {
+                if (nameEntry === part) {
+                  fallbackData = {
+                    name: part,
+                    header: potentialHeader,
+                    tables: potentialTables
+                  };
+                }
+              }
             }
           }
         }
 
+        if (fallbackData) {
+          (0, _util.warn)(`TrueType Collection does not contain "${fontName}" font, ` + `falling back to "${fallbackData.name}" font instead.`);
+          return {
+            header: fallbackData.header,
+            tables: fallbackData.tables
+          };
+        }
+
         throw new _util.FormatError(`TrueType Collection does not contain "${fontName}" font.`);
       }
 
@@ -30805,7 +31309,7 @@ var CFFFont = function CFFFontClosure() {
 }();
 
 /***/ }),
-/* 32 */
+/* 33 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -30817,9 +31321,9 @@ exports.CFFTopDict = exports.CFFStrings = exports.CFFStandardStrings = exports.C
 
 var _util = __w_pdfjs_require__(2);
 
-var _charsets = __w_pdfjs_require__(33);
+var _charsets = __w_pdfjs_require__(34);
 
-var _encodings = __w_pdfjs_require__(34);
+var _encodings = __w_pdfjs_require__(35);
 
 const MAX_SUBR_NESTING = 10;
 const 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"];
@@ -32641,7 +33145,7 @@ class CFFCompiler {
 exports.CFFCompiler = CFFCompiler;
 
 /***/ }),
-/* 33 */
+/* 34 */
 /***/ ((__unused_webpack_module, exports) => {
 
 
@@ -32658,7 +33162,7 @@ const ExpertSubsetCharset = [".notdef", "space", "dollaroldstyle", "dollarsuperi
 exports.ExpertSubsetCharset = ExpertSubsetCharset;
 
 /***/ }),
-/* 34 */
+/* 35 */
 /***/ ((__unused_webpack_module, exports) => {
 
 
@@ -32711,7 +33215,7 @@ function getEncoding(encodingName) {
 }
 
 /***/ }),
-/* 35 */
+/* 36 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -32733,7 +33237,7 @@ const getDingbatsGlyphsUnicode = (0, _core_utils.getArrayLookupTableFactory)(fun
 exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
 
 /***/ }),
-/* 36 */
+/* 37 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -33476,7 +33980,7 @@ const getSupplementalGlyphMapForCalibri = (0, _core_utils.getLookupTableFactory)
 exports.getSupplementalGlyphMapForCalibri = getSupplementalGlyphMapForCalibri;
 
 /***/ }),
-/* 37 */
+/* 38 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -33987,7 +34491,7 @@ function reverseIfRtl(chars) {
 }
 
 /***/ }),
-/* 38 */
+/* 39 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -33999,11 +34503,11 @@ exports.FontRendererFactory = void 0;
 
 var _util = __w_pdfjs_require__(2);
 
-var _cff_parser = __w_pdfjs_require__(32);
+var _cff_parser = __w_pdfjs_require__(33);
 
-var _glyphlist = __w_pdfjs_require__(35);
+var _glyphlist = __w_pdfjs_require__(36);
 
-var _encodings = __w_pdfjs_require__(34);
+var _encodings = __w_pdfjs_require__(35);
 
 var _stream = __w_pdfjs_require__(12);
 
@@ -34952,7 +35456,7 @@ const FontRendererFactory = function FontRendererFactoryClosure() {
 exports.FontRendererFactory = FontRendererFactory;
 
 /***/ }),
-/* 39 */
+/* 40 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -34962,7 +35466,7 @@ Object.defineProperty(exports, "__esModule", ({
 }));
 exports.Type1Parser = void 0;
 
-var _encodings = __w_pdfjs_require__(34);
+var _encodings = __w_pdfjs_require__(35);
 
 var _core_utils = __w_pdfjs_require__(8);
 
@@ -35675,7 +36179,7 @@ const Type1Parser = function Type1ParserClosure() {
 exports.Type1Parser = Type1Parser;
 
 /***/ }),
-/* 40 */
+/* 41 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -36619,7 +37123,7 @@ function getTilingPatternIR(operatorList, dict, color) {
 }
 
 /***/ }),
-/* 41 */
+/* 42 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -36634,7 +37138,7 @@ var _primitives = __w_pdfjs_require__(5);
 
 var _util = __w_pdfjs_require__(2);
 
-var _ps_parser = __w_pdfjs_require__(42);
+var _ps_parser = __w_pdfjs_require__(43);
 
 var _image_utils = __w_pdfjs_require__(24);
 
@@ -38049,7 +38553,7 @@ var PostScriptCompiler = function PostScriptCompilerClosure() {
 exports.PostScriptCompiler = PostScriptCompiler;
 
 /***/ }),
-/* 42 */
+/* 43 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -38302,7 +38806,7 @@ class PostScriptLexer {
 exports.PostScriptLexer = PostScriptLexer;
 
 /***/ }),
-/* 43 */
+/* 44 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -38613,7 +39117,7 @@ function bidi(str, startLevel, vertical) {
 }
 
 /***/ }),
-/* 44 */
+/* 45 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -41566,7 +42070,7 @@ const getMetrics = (0, _core_utils.getLookupTableFactory)(function (t) {
 exports.getMetrics = getMetrics;
 
 /***/ }),
-/* 45 */
+/* 46 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -41691,7 +42195,7 @@ class MurmurHash3_64 {
 exports.MurmurHash3_64 = MurmurHash3_64;
 
 /***/ }),
-/* 46 */
+/* 47 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -42353,7 +42857,7 @@ const OperatorList = function OperatorListClosure() {
 exports.OperatorList = OperatorList;
 
 /***/ }),
-/* 47 */
+/* 48 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -43026,7 +43530,7 @@ class PDFImage {
 exports.PDFImage = PDFImage;
 
 /***/ }),
-/* 48 */
+/* 49 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -43316,7 +43820,7 @@ function incrementalUpdate({
 }
 
 /***/ }),
-/* 49 */
+/* 50 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -43326,11 +43830,11 @@ Object.defineProperty(exports, "__esModule", ({
 }));
 exports.XFAFactory = void 0;
 
-var _xfa_object = __w_pdfjs_require__(50);
+var _xfa_object = __w_pdfjs_require__(51);
 
-var _bind = __w_pdfjs_require__(53);
+var _bind = __w_pdfjs_require__(54);
 
-var _parser = __w_pdfjs_require__(57);
+var _parser = __w_pdfjs_require__(58);
 
 class XFAFactory {
   constructor(data) {
@@ -43364,7 +43868,7 @@ class XFAFactory {
 exports.XFAFactory = XFAFactory;
 
 /***/ }),
-/* 50 */
+/* 51 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -43372,14 +43876,16 @@ exports.XFAFactory = XFAFactory;
 Object.defineProperty(exports, "__esModule", ({
   value: true
 }));
-exports.XmlObject = exports.XFAObjectArray = exports.XFAObject = exports.XFAAttribute = exports.StringObject = exports.OptionObject = exports.Option10 = exports.Option01 = exports.IntegerObject = exports.ContentObject = exports.$uid = exports.$toStyle = exports.$toHTML = exports.$text = exports.$setValue = exports.$setSetAttributes = exports.$setId = exports.$resolvePrototypes = exports.$removeChild = exports.$onText = exports.$onChildCheck = exports.$onChild = exports.$nsAttributes = exports.$nodeName = exports.$namespaceId = exports.$isTransparent = exports.$isDescendent = exports.$isDataValue = exports.$insertAt = exports.$indexOf = exports.$hasSettableValue = exports.$hasItem = exports.$global = exports.$getRealChildrenByNameIt = exports.$getParent = exports.$getChildrenByNameIt = exports.$getChildrenByName = exports.$getChildrenByClass = exports.$getChildren = exports.$getAttributeIt = exports.$finalize = exports.$extra = exports.$dump = exports.$data = exports.$content = exports.$consumed = exports.$clone = exports.$cleanup = exports.$clean = exports.$childrenToHTML = exports.$appendChild = void 0;
+exports.XmlObject = exports.XFAObjectArray = exports.XFAObject = exports.XFAAttribute = exports.StringObject = exports.OptionObject = exports.Option10 = exports.Option01 = exports.IntegerObject = exports.ContentObject = exports.$uid = exports.$toStyle = exports.$toHTML = exports.$text = exports.$setValue = exports.$setSetAttributes = exports.$setId = exports.$resolvePrototypes = exports.$removeChild = exports.$onText = exports.$onChildCheck = exports.$onChild = exports.$nsAttributes = exports.$nodeName = exports.$namespaceId = exports.$isTransparent = exports.$isDescendent = exports.$isDataValue = exports.$insertAt = exports.$indexOf = exports.$hasSettableValue = exports.$hasItem = exports.$global = exports.$getRealChildrenByNameIt = exports.$getParent = exports.$getChildrenByNameIt = exports.$getChildrenByName = exports.$getChildrenByClass = exports.$getChildren = exports.$getAttributeIt = exports.$finalize = exports.$extra = exports.$dump = exports.$data = exports.$content = exports.$consumed = exports.$clone = exports.$cleanup = exports.$clean = exports.$childrenToHTML = exports.$appendChild = exports.$acceptWhitespace = void 0;
 
-var _utils = __w_pdfjs_require__(51);
+var _utils = __w_pdfjs_require__(52);
 
 var _util = __w_pdfjs_require__(2);
 
-var _namespaces = __w_pdfjs_require__(52);
+var _namespaces = __w_pdfjs_require__(53);
 
+const $acceptWhitespace = Symbol();
+exports.$acceptWhitespace = $acceptWhitespace;
 const $appendChild = Symbol();
 exports.$appendChild = $appendChild;
 const $childrenToHTML = Symbol();
@@ -43545,6 +44051,10 @@ class XFAObject {
     return this.hasOwnProperty(child[$nodeName]) && child[$namespaceId] === this[$namespaceId];
   }
 
+  [$acceptWhitespace]() {
+    return false;
+  }
+
   [$setId](ids) {
     if (this.id && this[$namespaceId] === _namespaces.NamespaceIds.template.id) {
       ids.set(this.id, this);
@@ -44273,7 +44783,7 @@ class Option10 extends IntegerObject {
 exports.Option10 = Option10;
 
 /***/ }),
-/* 51 */
+/* 52 */
 /***/ ((__unused_webpack_module, exports) => {
 
 
@@ -44498,7 +45008,7 @@ function getBBox(data) {
 }
 
 /***/ }),
-/* 52 */
+/* 53 */
 /***/ ((__unused_webpack_module, exports) => {
 
 
@@ -44574,7 +45084,7 @@ const NamespaceIds = {
 exports.NamespaceIds = NamespaceIds;
 
 /***/ }),
-/* 53 */
+/* 54 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -44584,13 +45094,13 @@ Object.defineProperty(exports, "__esModule", ({
 }));
 exports.Binder = void 0;
 
-var _xfa_object = __w_pdfjs_require__(50);
+var _xfa_object = __w_pdfjs_require__(51);
 
-var _template = __w_pdfjs_require__(54);
+var _template = __w_pdfjs_require__(55);
 
-var _som = __w_pdfjs_require__(56);
+var _som = __w_pdfjs_require__(57);
 
-var _namespaces = __w_pdfjs_require__(52);
+var _namespaces = __w_pdfjs_require__(53);
 
 var _util = __w_pdfjs_require__(2);
 
@@ -45093,7 +45603,7 @@ class Binder {
 exports.Binder = Binder;
 
 /***/ }),
-/* 54 */
+/* 55 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -45103,13 +45613,13 @@ Object.defineProperty(exports, "__esModule", ({
 }));
 exports.Value = exports.Text = exports.TemplateNamespace = exports.Template = exports.SetProperty = exports.Items = exports.Field = exports.BindItems = void 0;
 
-var _xfa_object = __w_pdfjs_require__(50);
+var _xfa_object = __w_pdfjs_require__(51);
 
-var _namespaces = __w_pdfjs_require__(52);
+var _namespaces = __w_pdfjs_require__(53);
 
-var _utils = __w_pdfjs_require__(51);
+var _html_utils = __w_pdfjs_require__(56);
 
-var _html_utils = __w_pdfjs_require__(55);
+var _utils = __w_pdfjs_require__(52);
 
 var _util = __w_pdfjs_require__(2);
 
@@ -45196,6 +45706,32 @@ class Area extends _xfa_object.XFAObject {
     return true;
   }
 
+  [_xfa_object.$toHTML]() {
+    this[_xfa_object.$extra] = Object.create(null);
+    const style = (0, _html_utils.toStyle)(this, "position");
+    const attributes = {
+      style,
+      id: this[_xfa_object.$uid],
+      class: "xfaArea"
+    };
+
+    if (this.name) {
+      attributes.xfaName = this.name;
+    }
+
+    const children = this[_xfa_object.$childrenToHTML]({
+      filter: new Set(["area", "draw", "field", "subform", "subformSet"]),
+      include: true
+    });
+
+    const html = {
+      name: "div",
+      attributes,
+      children
+    };
+    return html;
+  }
+
 }
 
 class Assist extends _xfa_object.XFAObject {
@@ -45337,57 +45873,46 @@ class Border extends _xfa_object.XFAObject {
   }
 
   [_xfa_object.$toStyle](widths, margins) {
-    const edgeStyles = this.edge.children.map(node => node[_xfa_object.$toStyle]());
-    const cornerStyles = this.edge.children.map(node => node[_xfa_object.$toStyle]());
+    const edges = this.edge.children.slice();
+
+    if (edges.length < 4) {
+      const defaultEdge = edges[edges.length - 1] || new Edge({});
+
+      for (let i = edges.length; i < 4; i++) {
+        edges.push(defaultEdge);
+      }
+    }
+
+    if (widths) {
+      for (let i = 0; i < 4; i++) {
+        widths[i] = edges[i].thickness;
+      }
+    }
+
+    const edgeStyles = edges.map(node => node[_xfa_object.$toStyle]());
+    const cornerStyles = this.corner.children.map(node => node[_xfa_object.$toStyle]());
     let style;
 
     if (this.margin) {
       style = this.margin[_xfa_object.$toStyle]();
 
       if (margins) {
-        margins.push(this.margin.topInset, this.margin.rightInset, this.margin.bottomInset, this.margin.leftInset);
+        margins[0] = this.margin.topInset;
+        margins[1] = this.margin.rightInset;
+        margins[2] = this.margin.bottomInset;
+        margins[3] = this.margin.leftInset;
       }
     } else {
       style = Object.create(null);
-
-      if (margins) {
-        margins.push(0, 0, 0, 0);
-      }
     }
 
     if (this.fill) {
       Object.assign(style, this.fill[_xfa_object.$toStyle]());
     }
 
-    if (edgeStyles.length > 0) {
-      if (widths) {
-        this.edge.children.forEach(node => widths.push(node.thickness));
-
-        if (widths.length < 4) {
-          const last = widths[widths.length - 1];
-
-          for (let i = widths.length; i < 4; i++) {
-            widths.push(last);
-          }
-        }
-      }
-
-      if (edgeStyles.length === 2 || edgeStyles.length === 3) {
-        const last = edgeStyles[edgeStyles.length - 1];
-
-        for (let i = edgeStyles.length; i < 4; i++) {
-          edgeStyles.push(last);
-        }
-      }
-
-      style.borderWidth = edgeStyles.map(s => s.width).join(" ");
-      style.borderColor = edgeStyles.map(s => s.color).join(" ");
-      style.borderStyle = edgeStyles.map(s => s.style).join(" ");
-    } else {
-      if (widths) {
-        widths.push(0, 0, 0, 0);
-      }
-    }
+    style.borderWidth = edgeStyles.map(s => s.width).join(" ");
+    style.borderColor = edgeStyles.map(s => s.color).join(" ");
+    style.borderStyle = edgeStyles.map(s => s.style).join(" ");
 
     if (cornerStyles.length > 0) {
       if (cornerStyles.length === 2 || cornerStyles.length === 3) {
@@ -45636,7 +46161,7 @@ class CheckButton extends _xfa_object.XFAObject {
     let mark, radius;
 
     if (this.shape === "square") {
-      mark = "â– ";
+      mark = "â–ª";
       radius = "10%";
     } else {
       mark = "●";
@@ -45666,7 +46191,7 @@ class CheckButton extends _xfa_object.XFAObject {
           break;
 
         case "square":
-          mark = "â– ";
+          mark = "â–ª";
           break;
 
         case "star":
@@ -45734,7 +46259,7 @@ class ChoiceList extends _xfa_object.XFAObject {
       children: [{
         name: "select",
         attributes: {
-          class: "xfaSxelect",
+          class: "xfaSelect",
           multiple: this.open === "multiSelect",
           style
         }
@@ -46071,7 +46596,7 @@ class Draw extends _xfa_object.XFAObject {
       return null;
     }
 
-    const style = (0, _html_utils.toStyle)(this, "font", "dimensions", "position", "presence", "rotate", "anchorType");
+    const style = (0, _html_utils.toStyle)(this, "font", "hAlign", "dimensions", "position", "presence", "rotate", "anchorType", "borderMarginPadding");
     const clazz = ["xfaDraw"];
 
     if (this.font) {
@@ -46088,11 +46613,35 @@ class Draw extends _xfa_object.XFAObject {
       attributes.xfaName = this.name;
     }
 
-    return {
+    let html = {
       name: "div",
       attributes,
       children: []
     };
+    const value = this.value ? this.value[_xfa_object.$toHTML]() : null;
+
+    if (value === null) {
+      return html;
+    }
+
+    html.children.push(value);
+
+    if (this.para && value.attributes.class === "xfaRich") {
+      const paraStyle = this.para[_xfa_object.$toStyle]();
+
+      if (!value.attributes.style) {
+        value.attributes.style = paraStyle;
+      } else {
+        for (const [key, val] of Object.entries(paraStyle)) {
+          if (!(key in value.attributes.style)) {
+            value.attributes.style[key] = val;
+          }
+        }
+      }
+    }
+
+    html = (0, _html_utils.addExtraDivForMargin)(html);
+    return html;
   }
 
 }
@@ -46300,6 +46849,14 @@ class ExData extends _xfa_object.ContentObject {
     return false;
   }
 
+  [_xfa_object.$toHTML]() {
+    if (this.contentType !== "text/html" || !this[_xfa_object.$content]) {
+      return null;
+    }
+
+    return this[_xfa_object.$content][_xfa_object.$toHTML]();
+  }
+
 }
 
 class ExObject extends _xfa_object.XFAObject {
@@ -46526,26 +47083,7 @@ class Field extends _xfa_object.XFAObject {
       return null;
     }
 
-    const style = (0, _html_utils.toStyle)(this, "font", "dimensions", "position", "rotate", "anchorType", "presence");
-    const borderWidths = [];
-    const marginWidths = [];
-
-    if (this.border) {
-      Object.assign(style, this.border[_xfa_object.$toStyle](borderWidths, marginWidths));
-    }
-
-    if (this.margin) {
-      style.paddingTop = (0, _html_utils.measureToString)(this.margin.topInset - borderWidths[0] - marginWidths[0]);
-      style.paddingRight = (0, _html_utils.measureToString)(this.margin.rightInset - borderWidths[1] - marginWidths[1]);
-      style.paddingBottom = (0, _html_utils.measureToString)(this.margin.bottomInset - borderWidths[2] - marginWidths[2]);
-      style.paddingLeft = (0, _html_utils.measureToString)(this.margin.leftInset - borderWidths[3] - marginWidths[3]);
-    } else {
-      style.paddingTop = (0, _html_utils.measureToString)(-borderWidths[0] - marginWidths[0]);
-      style.paddingRight = (0, _html_utils.measureToString)(-borderWidths[1] - marginWidths[1]);
-      style.paddingBottom = (0, _html_utils.measureToString)(-borderWidths[2] - marginWidths[2]);
-      style.paddingLeft = (0, _html_utils.measureToString)(-borderWidths[3] - marginWidths[3]);
-    }
-
+    const style = (0, _html_utils.toStyle)(this, "font", "dimensions", "position", "rotate", "anchorType", "presence", "borderMarginPadding");
     const clazz = ["xfaField"];
 
     if (this.font) {
@@ -46563,7 +47101,7 @@ class Field extends _xfa_object.XFAObject {
     }
 
     const children = [];
-    const html = {
+    let html = {
       name: "div",
       attributes,
       children
@@ -46581,7 +47119,7 @@ class Field extends _xfa_object.XFAObject {
     children.push(ui);
 
     if (this.value && ui.name !== "button") {
-      ui.children[0].attributes.value = this.value[_xfa_object.$toHTML]();
+      ui.children[0].attributes.value = this.value[_xfa_object.$toHTML]().value;
     }
 
     const caption = this.caption ? this.caption[_xfa_object.$toHTML]() : null;
@@ -46591,8 +47129,8 @@ class Field extends _xfa_object.XFAObject {
     }
 
     if (ui.name === "button") {
-      ui.attributes.style.background = style.color;
-      delete style.color;
+      ui.attributes.style.background = style.background;
+      delete style.background;
 
       if (caption.name === "div") {
         caption.name = "span";
@@ -46627,6 +47165,7 @@ class Field extends _xfa_object.XFAObject {
         break;
     }
 
+    html = (0, _html_utils.addExtraDivForMargin)(html);
     return html;
   }
 
@@ -46667,9 +47206,13 @@ class Fill extends _xfa_object.XFAObject {
       };
     }
 
-    return {
-      color: this.color ? this.color[_xfa_object.$toStyle]() : "#000000"
-    };
+    if (this.color) {
+      return {
+        background: this.color[_xfa_object.$toStyle]()
+      };
+    }
+
+    return {};
   }
 
 }
@@ -46768,14 +47311,17 @@ class Font extends _xfa_object.XFAObject {
 
   [_xfa_object.$toStyle]() {
     const style = (0, _html_utils.toStyle)(this, "fill");
+    const color = style.background;
 
-    if (style.color) {
-      if (!style.color.startsWith("#")) {
+    if (color) {
+      if (color === "#000000") {
+        delete style.background;
+      } else if (!color.startsWith("#")) {
         style.backgroundClip = "text";
-        style.background = style.color;
         style.color = "transparent";
-      } else if (style.color === "#000000") {
-        delete style.color;
+      } else {
+        style.color = color;
+        delete style.background;
       }
     }
 
@@ -46916,6 +47462,7 @@ class Image extends _xfa_object.StringObject {
     const html = {
       name: "img",
       attributes: {
+        class: "xfaImage",
         style: {}
       }
     };
@@ -47132,10 +47679,7 @@ class Margin extends _xfa_object.XFAObject {
 
   [_xfa_object.$toStyle]() {
     return {
-      marginLeft: (0, _html_utils.measureToString)(this.leftInset),
-      marginRight: (0, _html_utils.measureToString)(this.rightInset),
-      marginTop: (0, _html_utils.measureToString)(this.topInset),
-      marginBottom: (0, _html_utils.measureToString)(this.bottomInset)
+      margin: (0, _html_utils.measureToString)(this.topInset) + " " + (0, _html_utils.measureToString)(this.rightInset) + " " + (0, _html_utils.measureToString)(this.bottomInset) + " " + (0, _html_utils.measureToString)(this.leftInset)
     };
   }
 
@@ -47381,21 +47925,21 @@ class Para extends _xfa_object.XFAObject {
     super(TEMPLATE_NS_ID, "para", true);
     this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
     this.id = attributes.id || "";
-    this.lineHeight = (0, _utils.getMeasurement)(attributes.lineHeight, "0pt");
-    this.marginLeft = (0, _utils.getMeasurement)(attributes.marginLeft, "0");
-    this.marginRight = (0, _utils.getMeasurement)(attributes.marginRight, "0");
+    this.lineHeight = attributes.lineHeight ? (0, _utils.getMeasurement)(attributes.lineHeight, "0pt") : "";
+    this.marginLeft = attributes.marginLeft ? (0, _utils.getMeasurement)(attributes.marginLeft, "0pt") : "";
+    this.marginRight = attributes.marginRight ? (0, _utils.getMeasurement)(attributes.marginRight, "0pt") : "";
     this.orphans = (0, _utils.getInteger)({
       data: attributes.orphans,
       defaultValue: 0,
       validate: x => x >= 0
     });
     this.preserve = attributes.preserve || "";
-    this.radixOffset = (0, _utils.getMeasurement)(attributes.radixOffset, "0");
-    this.spaceAbove = (0, _utils.getMeasurement)(attributes.spaceAbove, "0");
-    this.spaceBelow = (0, _utils.getMeasurement)(attributes.spaceBelow, "0");
-    this.tabDefault = attributes.tabDefault ? (0, _utils.getMeasurement)(this.tabDefault) : null;
+    this.radixOffset = attributes.radixOffset ? (0, _utils.getMeasurement)(attributes.radixOffset, "0pt") : "";
+    this.spaceAbove = attributes.spaceAbove ? (0, _utils.getMeasurement)(attributes.spaceAbove, "0pt") : "";
+    this.spaceBelow = attributes.spaceBelow ? (0, _utils.getMeasurement)(attributes.spaceBelow, "0pt") : "";
+    this.tabDefault = attributes.tabDefault ? (0, _utils.getMeasurement)(this.tabDefault) : "";
     this.tabStops = (attributes.tabStops || "").trim().split(/\s+/).map((x, i) => i % 2 === 1 ? (0, _utils.getMeasurement)(x) : x);
-    this.textIndent = (0, _utils.getMeasurement)(attributes.textIndent, "0");
+    this.textIndent = attributes.textIndent ? (0, _utils.getMeasurement)(attributes.textIndent, "0pt") : "";
     this.use = attributes.use || "";
     this.usehref = attributes.usehref || "";
     this.vAlign = (0, _utils.getStringOption)(attributes.vAlign, ["top", "bottom", "middle"]);
@@ -47407,28 +47951,41 @@ class Para extends _xfa_object.XFAObject {
     this.hyphenation = null;
   }
 
-  [_xfa_object.$toHTML]() {
-    const style = {
-      marginLeft: (0, _html_utils.measureToString)(this.marginLeft),
-      marginRight: (0, _html_utils.measureToString)(this.marginRight),
-      paddingTop: (0, _html_utils.measureToString)(this.spaceAbove),
-      paddingBottom: (0, _html_utils.measureToString)(this.spaceBelow),
-      textIndent: (0, _html_utils.measureToString)(this.textIndent),
-      verticalAlign: this.vAlign
-    };
+  [_xfa_object.$toStyle]() {
+    const style = (0, _html_utils.toStyle)(this, "hAlign");
+
+    if (this.marginLeft !== "") {
+      style.marginLeft = (0, _html_utils.measureToString)(this.marginLeft);
+    }
 
-    if (this.lineHeight.value >= 0) {
+    if (this.marginRight !== "") {
+      style.marginRight = (0, _html_utils.measureToString)(this.marginRight);
+    }
+
+    if (this.spaceAbove !== "") {
+      style.marginTop = (0, _html_utils.measureToString)(this.spaceAbove);
+    }
+
+    if (this.spaceBelow !== "") {
+      style.marginBottom = (0, _html_utils.measureToString)(this.spaceBelow);
+    }
+
+    if (this.textIndent !== "") {
+      style.textIndent = (0, _html_utils.measureToString)(this.textIndent);
+    }
+
+    if (this.lineHeight !== "") {
       style.lineHeight = (0, _html_utils.measureToString)(this.lineHeight);
     }
 
-    if (this.tabDefault) {
+    if (this.tabDefault !== "") {
       style.tabSize = (0, _html_utils.measureToString)(this.tabDefault);
     }
 
     if (this.tabStops.length > 0) {}
 
     if (this.hyphenatation) {
-      Object.assign(style, this.hyphenatation[_xfa_object.$toHTML]());
+      Object.assign(style, this.hyphenatation[_xfa_object.$toStyle]());
     }
 
     return style;
@@ -47882,6 +48439,15 @@ class Subform extends _xfa_object.XFAObject {
   [_xfa_object.$toHTML]() {
     this[_xfa_object.$extra] = Object.create(null);
 
+    if (this.layout === "row") {
+      const columnWidths = this[_xfa_object.$getParent]().columnWidths;
+
+      if (Array.isArray(columnWidths) && columnWidths.length > 0) {
+        this[_xfa_object.$extra].columnWidths = columnWidths;
+        this[_xfa_object.$extra].currentColumn = 0;
+      }
+    }
+
     const parent = this[_xfa_object.$getParent]();
 
     let page = null;
@@ -48080,7 +48646,48 @@ class Text extends _xfa_object.ContentObject {
 
   [_xfa_object.$toHTML]() {
     if (typeof this[_xfa_object.$content] === "string") {
-      return this[_xfa_object.$content];
+      const html = {
+        name: "span",
+        attributes: {
+          class: "xfaRich",
+          style: {}
+        },
+        value: this[_xfa_object.$content]
+      };
+
+      if (this[_xfa_object.$content].includes("\u2029")) {
+        html.name = "div";
+        html.children = [];
+
+        this[_xfa_object.$content].split("\u2029").map(para => para.split(/[\u2028\n]/).reduce((acc, line) => {
+          acc.push({
+            name: "span",
+            value: line
+          }, {
+            name: "br"
+          });
+          return acc;
+        }, [])).forEach(lines => {
+          html.children.push({
+            name: "p",
+            children: lines
+          });
+        });
+      } else if (/[\u2028\n]/.test(this[_xfa_object.$content])) {
+        html.name = "div";
+        html.children = [];
+
+        this[_xfa_object.$content].split(/[\u2028\n]/).forEach(line => {
+          html.children.push({
+            name: "span",
+            value: line
+          }, {
+            name: "br"
+          });
+        });
+      }
+
+      return html;
     }
 
     return this[_xfa_object.$content][_xfa_object.$toHTML]();
@@ -48118,10 +48725,11 @@ class TextEdit extends _xfa_object.XFAObject {
     const style = (0, _html_utils.toStyle)(this, "border", "font", "margin");
     let html;
 
-    if (this.multiline === 1) {
+    if (this.multiLine === 1) {
       html = {
         name: "textarea",
         attributes: {
+          class: "xfaTextfield",
           style
         }
       };
@@ -48845,7 +49453,7 @@ class TemplateNamespace {
 exports.TemplateNamespace = TemplateNamespace;
 
 /***/ }),
-/* 55 */
+/* 56 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -48853,11 +49461,12 @@ exports.TemplateNamespace = TemplateNamespace;
 Object.defineProperty(exports, "__esModule", ({
   value: true
 }));
+exports.addExtraDivForMargin = addExtraDivForMargin;
 exports.layoutClass = layoutClass;
 exports.measureToString = measureToString;
 exports.toStyle = toStyle;
 
-var _xfa_object = __w_pdfjs_require__(50);
+var _xfa_object = __w_pdfjs_require__(51);
 
 var _util = __w_pdfjs_require__(2);
 
@@ -48911,8 +49520,18 @@ const converters = {
   },
 
   dimensions(node, style) {
-    if (node.w) {
-      style.width = measureToString(node.w);
+    const parent = node[_xfa_object.$getParent]();
+
+    const extra = parent[_xfa_object.$extra];
+    let width = node.w;
+
+    if (extra && extra.columnWidths) {
+      width = extra.columnWidths[extra.currentColumn];
+      extra.currentColumn = (extra.currentColumn + 1) % extra.columnWidths.length;
+    }
+
+    if (width !== "") {
+      style.width = measureToString(width);
     } else {
       style.width = "auto";
 
@@ -48923,7 +49542,7 @@ const converters = {
       style.minWidth = measureToString(node.minW);
     }
 
-    if (node.h) {
+    if (node.h !== "") {
       style.height = measureToString(node.h);
     } else {
       style.height = "auto";
@@ -48970,6 +49589,42 @@ const converters = {
         style.display = "none";
         break;
     }
+  },
+
+  hAlign(node, style) {
+    switch (node.hAlign) {
+      case "justifyAll":
+        style.textAlign = "justify-all";
+        break;
+
+      case "radix":
+        style.textAlign = "left";
+        break;
+
+      default:
+        style.textAlign = node.hAlign;
+    }
+  },
+
+  borderMarginPadding(node, style) {
+    const borderWidths = [0, 0, 0, 0];
+    const marginWidths = [0, 0, 0, 0];
+    const marginNode = node.margin ? [node.margin.topInset, node.margin.rightInset, node.margin.bottomInset, node.margin.leftInset] : [0, 0, 0, 0];
+
+    if (node.border) {
+      Object.assign(style, node.border[_xfa_object.$toStyle](borderWidths, marginWidths));
+    }
+
+    if (borderWidths.every(x => x === 0)) {
+      if (node.margin) {
+        Object.assign(style, node.margin[_xfa_object.$toStyle]());
+      }
+
+      style.padding = style.margin;
+      delete style.margin;
+    } else {
+      style.padding = measureToString(marginNode[0] - borderWidths[0] - marginWidths[0]) + " " + measureToString(marginNode[1] - borderWidths[1] - marginWidths[1]) + " " + measureToString(marginNode[2] - borderWidths[2] - marginWidths[2]) + " " + measureToString(marginNode[3] - borderWidths[3] - marginWidths[3]);
+    }
   }
 
 };
@@ -49032,8 +49687,34 @@ function toStyle(node, ...names) {
   return style;
 }
 
+function addExtraDivForMargin(html) {
+  const style = html.attributes.style;
+
+  if (style.margin) {
+    const padding = style.margin;
+    delete style.margin;
+    const width = style.width || "auto";
+    const height = style.height || "auto";
+    style.width = "100%";
+    style.height = "100%";
+    return {
+      name: "div",
+      attributes: {
+        style: {
+          padding,
+          width,
+          height
+        }
+      },
+      children: [html]
+    };
+  }
+
+  return html;
+}
+
 /***/ }),
-/* 56 */
+/* 57 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -49044,7 +49725,7 @@ Object.defineProperty(exports, "__esModule", ({
 exports.createDataNode = createDataNode;
 exports.searchNode = searchNode;
 
-var _xfa_object = __w_pdfjs_require__(50);
+var _xfa_object = __w_pdfjs_require__(51);
 
 var _util = __w_pdfjs_require__(2);
 
@@ -49349,7 +50030,7 @@ function createDataNode(root, container, expr) {
 }
 
 /***/ }),
-/* 57 */
+/* 58 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -49359,11 +50040,11 @@ Object.defineProperty(exports, "__esModule", ({
 }));
 exports.XFAParser = void 0;
 
-var _xfa_object = __w_pdfjs_require__(50);
+var _xfa_object = __w_pdfjs_require__(51);
 
 var _xml_parser = __w_pdfjs_require__(26);
 
-var _builder = __w_pdfjs_require__(58);
+var _builder = __w_pdfjs_require__(59);
 
 var _util = __w_pdfjs_require__(2);
 
@@ -49391,6 +50072,12 @@ class XFAParser extends _xml_parser.XMLParserBase {
   }
 
   onText(text) {
+    if (this._current[_xfa_object.$acceptWhitespace]()) {
+      this._current[_xfa_object.$onText](text);
+
+      return;
+    }
+
     if (this._whiteRegex.test(text)) {
       return;
     }
@@ -49518,7 +50205,7 @@ class XFAParser extends _xml_parser.XMLParserBase {
 exports.XFAParser = XFAParser;
 
 /***/ }),
-/* 58 */
+/* 59 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -49528,15 +50215,15 @@ Object.defineProperty(exports, "__esModule", ({
 }));
 exports.Builder = void 0;
 
-var _namespaces = __w_pdfjs_require__(52);
+var _namespaces = __w_pdfjs_require__(53);
 
-var _xfa_object = __w_pdfjs_require__(50);
+var _xfa_object = __w_pdfjs_require__(51);
 
-var _setup = __w_pdfjs_require__(59);
+var _setup = __w_pdfjs_require__(60);
 
-var _template = __w_pdfjs_require__(54);
+var _template = __w_pdfjs_require__(55);
 
-var _unknown = __w_pdfjs_require__(68);
+var _unknown = __w_pdfjs_require__(69);
 
 var _util = __w_pdfjs_require__(2);
 
@@ -49734,7 +50421,7 @@ class Builder {
 exports.Builder = Builder;
 
 /***/ }),
-/* 59 */
+/* 60 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -49744,23 +50431,23 @@ Object.defineProperty(exports, "__esModule", ({
 }));
 exports.NamespaceSetUp = void 0;
 
-var _config = __w_pdfjs_require__(60);
+var _config = __w_pdfjs_require__(61);
 
-var _connection_set = __w_pdfjs_require__(61);
+var _connection_set = __w_pdfjs_require__(62);
 
-var _datasets = __w_pdfjs_require__(62);
+var _datasets = __w_pdfjs_require__(63);
 
-var _locale_set = __w_pdfjs_require__(63);
+var _locale_set = __w_pdfjs_require__(64);
 
-var _signature = __w_pdfjs_require__(64);
+var _signature = __w_pdfjs_require__(65);
 
-var _stylesheet = __w_pdfjs_require__(65);
+var _stylesheet = __w_pdfjs_require__(66);
 
-var _template = __w_pdfjs_require__(54);
+var _template = __w_pdfjs_require__(55);
 
-var _xdp = __w_pdfjs_require__(66);
+var _xdp = __w_pdfjs_require__(67);
 
-var _xhtml = __w_pdfjs_require__(67);
+var _xhtml = __w_pdfjs_require__(68);
 
 const NamespaceSetUp = {
   config: _config.ConfigNamespace,
@@ -49776,7 +50463,7 @@ const NamespaceSetUp = {
 exports.NamespaceSetUp = NamespaceSetUp;
 
 /***/ }),
-/* 60 */
+/* 61 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -49786,11 +50473,11 @@ Object.defineProperty(exports, "__esModule", ({
 }));
 exports.ConfigNamespace = void 0;
 
-var _namespaces = __w_pdfjs_require__(52);
+var _namespaces = __w_pdfjs_require__(53);
 
-var _xfa_object = __w_pdfjs_require__(50);
+var _xfa_object = __w_pdfjs_require__(51);
 
-var _utils = __w_pdfjs_require__(51);
+var _utils = __w_pdfjs_require__(52);
 
 var _util = __w_pdfjs_require__(2);
 
@@ -51665,7 +52352,7 @@ class ConfigNamespace {
 exports.ConfigNamespace = ConfigNamespace;
 
 /***/ }),
-/* 61 */
+/* 62 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -51675,9 +52362,9 @@ Object.defineProperty(exports, "__esModule", ({
 }));
 exports.ConnectionSetNamespace = void 0;
 
-var _namespaces = __w_pdfjs_require__(52);
+var _namespaces = __w_pdfjs_require__(53);
 
-var _xfa_object = __w_pdfjs_require__(50);
+var _xfa_object = __w_pdfjs_require__(51);
 
 const CONNECTION_SET_NS_ID = _namespaces.NamespaceIds.connectionSet.id;
 
@@ -51879,7 +52566,7 @@ class ConnectionSetNamespace {
 exports.ConnectionSetNamespace = ConnectionSetNamespace;
 
 /***/ }),
-/* 62 */
+/* 63 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -51889,9 +52576,9 @@ Object.defineProperty(exports, "__esModule", ({
 }));
 exports.DatasetsNamespace = void 0;
 
-var _xfa_object = __w_pdfjs_require__(50);
+var _xfa_object = __w_pdfjs_require__(51);
 
-var _namespaces = __w_pdfjs_require__(52);
+var _namespaces = __w_pdfjs_require__(53);
 
 const DATASETS_NS_ID = _namespaces.NamespaceIds.datasets.id;
 
@@ -51945,7 +52632,7 @@ class DatasetsNamespace {
 exports.DatasetsNamespace = DatasetsNamespace;
 
 /***/ }),
-/* 63 */
+/* 64 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -51955,11 +52642,11 @@ Object.defineProperty(exports, "__esModule", ({
 }));
 exports.LocaleSetNamespace = void 0;
 
-var _namespaces = __w_pdfjs_require__(52);
+var _namespaces = __w_pdfjs_require__(53);
 
-var _xfa_object = __w_pdfjs_require__(50);
+var _xfa_object = __w_pdfjs_require__(51);
 
-var _utils = __w_pdfjs_require__(51);
+var _utils = __w_pdfjs_require__(52);
 
 const LOCALE_SET_NS_ID = _namespaces.NamespaceIds.localeSet.id;
 
@@ -52283,7 +52970,7 @@ class LocaleSetNamespace {
 exports.LocaleSetNamespace = LocaleSetNamespace;
 
 /***/ }),
-/* 64 */
+/* 65 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -52293,9 +52980,9 @@ Object.defineProperty(exports, "__esModule", ({
 }));
 exports.SignatureNamespace = void 0;
 
-var _namespaces = __w_pdfjs_require__(52);
+var _namespaces = __w_pdfjs_require__(53);
 
-var _xfa_object = __w_pdfjs_require__(50);
+var _xfa_object = __w_pdfjs_require__(51);
 
 const SIGNATURE_NS_ID = _namespaces.NamespaceIds.signature.id;
 
@@ -52324,7 +53011,7 @@ class SignatureNamespace {
 exports.SignatureNamespace = SignatureNamespace;
 
 /***/ }),
-/* 65 */
+/* 66 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -52334,9 +53021,9 @@ Object.defineProperty(exports, "__esModule", ({
 }));
 exports.StylesheetNamespace = void 0;
 
-var _namespaces = __w_pdfjs_require__(52);
+var _namespaces = __w_pdfjs_require__(53);
 
-var _xfa_object = __w_pdfjs_require__(50);
+var _xfa_object = __w_pdfjs_require__(51);
 
 const STYLESHEET_NS_ID = _namespaces.NamespaceIds.stylesheet.id;
 
@@ -52365,7 +53052,7 @@ class StylesheetNamespace {
 exports.StylesheetNamespace = StylesheetNamespace;
 
 /***/ }),
-/* 66 */
+/* 67 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -52375,9 +53062,9 @@ Object.defineProperty(exports, "__esModule", ({
 }));
 exports.XdpNamespace = void 0;
 
-var _namespaces = __w_pdfjs_require__(52);
+var _namespaces = __w_pdfjs_require__(53);
 
-var _xfa_object = __w_pdfjs_require__(50);
+var _xfa_object = __w_pdfjs_require__(51);
 
 const XDP_NS_ID = _namespaces.NamespaceIds.xdp.id;
 
@@ -52419,7 +53106,7 @@ class XdpNamespace {
 exports.XdpNamespace = XdpNamespace;
 
 /***/ }),
-/* 67 */
+/* 68 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -52429,12 +53116,57 @@ Object.defineProperty(exports, "__esModule", ({
 }));
 exports.XhtmlNamespace = void 0;
 
-var _namespaces = __w_pdfjs_require__(52);
+var _xfa_object = __w_pdfjs_require__(51);
+
+var _namespaces = __w_pdfjs_require__(53);
+
+var _utils = __w_pdfjs_require__(52);
 
-var _xfa_object = __w_pdfjs_require__(50);
+var _html_utils = __w_pdfjs_require__(56);
 
 const XHTML_NS_ID = _namespaces.NamespaceIds.xhtml.id;
-const VALID_STYLES = new Set(["color", "font", "font-family", "font-size", "font-stretch", "font-style", "font-weight", "margin", "margin-bottom", "margin-left", "margin-right", "margin-top", "letter-spacing", "line-height", "orphans", "page-break-after", "page-break-before", "page-break-inside", "tab-interval", "tab-stop", "text-decoration", "text-indent", "vertical-align", "widows", "kerning-mode", "xfa-font-horizontal-scale", "xfa-font-vertical-scale", "xfa-tab-stops"]);
+const VALID_STYLES = new Set(["color", "font", "font-family", "font-size", "font-stretch", "font-style", "font-weight", "margin", "margin-bottom", "margin-left", "margin-right", "margin-top", "letter-spacing", "line-height", "orphans", "page-break-after", "page-break-before", "page-break-inside", "tab-interval", "tab-stop", "text-align", "text-decoration", "text-indent", "vertical-align", "widows", "kerning-mode", "xfa-font-horizontal-scale", "xfa-font-vertical-scale", "xfa-spacerun", "xfa-tab-stops"]);
+const StyleMapping = new Map([["page-break-after", "breakAfter"], ["page-break-before", "breakBefore"], ["page-break-inside", "breakInside"], ["kerning-mode", value => value === "none" ? "none" : "normal"], ["xfa-font-horizontal-scale", value => `scaleX(${Math.max(0, Math.min(parseInt(value) / 100)).toFixed(2)})`], ["xfa-font-vertical-scale", value => `scaleY(${Math.max(0, Math.min(parseInt(value) / 100)).toFixed(2)})`], ["xfa-spacerun", ""], ["xfa-tab-stops", ""], ["font-size", value => (0, _html_utils.measureToString)((0, _utils.getMeasurement)(value))], ["letter-spacing", value => (0, _html_utils.measureToString)((0, _utils.getMeasurement)(value))], ["line-height", value => (0, _html_utils.measureToString)((0, _utils.getMeasurement)(value))], ["margin", value => (0, _html_utils.measureToString)((0, _utils.getMeasurement)(value))], ["margin-bottom", value => (0, _html_utils.measureToString)((0, _utils.getMeasurement)(value))], ["margin-left", value => (0, _html_utils.measureToString)((0, _utils.getMeasurement)(value))], ["margin-right", value => (0, _html_utils.measureToString)((0, _utils.getMeasurement)(value))], ["margin-top", value => (0, _html_utils.measureToString)((0, _utils.getMeasurement)(value))]]);
+const spacesRegExp = /\s+/g;
+const crlfRegExp = /[\r\n]+/g;
+
+function mapStyle(styleStr) {
+  const style = Object.create(null);
+
+  if (!styleStr) {
+    return style;
+  }
+
+  for (const [key, value] of styleStr.split(";").map(s => s.split(":", 2))) {
+    const mapping = StyleMapping.get(key);
+
+    if (mapping === "") {
+      continue;
+    }
+
+    let newValue = value;
+
+    if (mapping) {
+      if (typeof mapping === "string") {
+        newValue = mapping;
+      } else {
+        newValue = mapping(value);
+      }
+    }
+
+    if (key.endsWith("scale")) {
+      if (style.transform) {
+        style.transform = `${style[key]} ${newValue}`;
+      } else {
+        style.transform = newValue;
+      }
+    } else {
+      style[key.replaceAll(/-([a-zA-Z])/g, (_, x) => x.toUpperCase())] = newValue;
+    }
+  }
+
+  return style;
+}
 
 function checkStyle(style) {
   if (!style) {
@@ -52444,111 +53176,181 @@ function checkStyle(style) {
   return style.trim().split(/\s*;\s*/).filter(s => !!s).map(s => s.split(/\s*:\s*/, 2)).filter(([key]) => VALID_STYLES.has(key)).map(kv => kv.join(":")).join(";");
 }
 
-class A extends _xfa_object.XmlObject {
+const NoWhites = new Set(["body", "html"]);
+
+class XhtmlObject extends _xfa_object.XmlObject {
+  constructor(attributes, name) {
+    super(XHTML_NS_ID, name);
+    this.style = checkStyle(attributes.style);
+  }
+
+  [_xfa_object.$acceptWhitespace]() {
+    return !NoWhites.has(this[_xfa_object.$nodeName]);
+  }
+
+  [_xfa_object.$onText](str) {
+    str = str.replace(crlfRegExp, "");
+
+    if (!this.style.includes("xfa-spacerun:yes")) {
+      str = str.replace(spacesRegExp, " ");
+    }
+
+    if (str) {
+      this[_xfa_object.$content] += str;
+    }
+  }
+
+  [_xfa_object.$toHTML]() {
+    return {
+      name: this[_xfa_object.$nodeName],
+      attributes: {
+        href: this.href,
+        style: mapStyle(this.style)
+      },
+      children: this[_xfa_object.$childrenToHTML]({}),
+      value: this[_xfa_object.$content] || ""
+    };
+  }
+
+}
+
+class A extends XhtmlObject {
   constructor(attributes) {
-    super(XHTML_NS_ID, "a");
+    super(attributes, "a");
     this.href = attributes.href || "";
-    this.style = checkStyle(attributes.style);
   }
 
 }
 
-class B extends _xfa_object.XmlObject {
+class B extends XhtmlObject {
   constructor(attributes) {
-    super(XHTML_NS_ID, "b");
-    this.style = checkStyle(attributes.style);
+    super(attributes, "b");
   }
 
 }
 
-class Body extends _xfa_object.XmlObject {
+class Body extends XhtmlObject {
   constructor(attributes) {
-    super(XHTML_NS_ID, "body");
-    this.style = checkStyle(attributes.style);
+    super(attributes, "body");
+  }
+
+  [_xfa_object.$toHTML]() {
+    const html = super[_xfa_object.$toHTML]();
+
+    html.attributes.class = "xfaRich";
+    return html;
   }
 
 }
 
-class Br extends _xfa_object.XmlObject {
+class Br extends XhtmlObject {
   constructor(attributes) {
-    super(XHTML_NS_ID, "br");
-    this.style = checkStyle(attributes.style);
+    super(attributes, "br");
   }
 
   [_xfa_object.$text]() {
     return "\n";
   }
 
+  [_xfa_object.$toHTML]() {
+    return {
+      name: "br"
+    };
+  }
+
 }
 
-class Html extends _xfa_object.XmlObject {
+class Html extends XhtmlObject {
   constructor(attributes) {
-    super(XHTML_NS_ID, "html");
-    this.style = checkStyle(attributes.style);
+    super(attributes, "html");
+  }
+
+  [_xfa_object.$toHTML]() {
+    const children = this[_xfa_object.$childrenToHTML]({});
+
+    if (children.length === 0) {
+      return {
+        name: "div",
+        attributes: {
+          class: "xfaRich",
+          style: {}
+        },
+        value: this[_xfa_object.$content] || ""
+      };
+    }
+
+    if (children.length === 1) {
+      const child = children[0];
+
+      if (child.attributes && child.attributes.class === "xfaRich") {
+        return child;
+      }
+    }
+
+    return {
+      name: "div",
+      attributes: {
+        class: "xfaRich",
+        style: {}
+      },
+      children
+    };
   }
 
 }
 
-class I extends _xfa_object.XmlObject {
+class I extends XhtmlObject {
   constructor(attributes) {
-    super(XHTML_NS_ID, "i");
-    this.style = checkStyle(attributes.style);
+    super(attributes, "i");
   }
 
 }
 
-class Li extends _xfa_object.XmlObject {
+class Li extends XhtmlObject {
   constructor(attributes) {
-    super(XHTML_NS_ID, "li");
-    this.style = checkStyle(attributes.style);
+    super(attributes, "li");
   }
 
 }
 
-class Ol extends _xfa_object.XmlObject {
+class Ol extends XhtmlObject {
   constructor(attributes) {
-    super(XHTML_NS_ID, "ol");
-    this.style = checkStyle(attributes.style);
+    super(attributes, "ol");
   }
 
 }
 
-class P extends _xfa_object.XmlObject {
+class P extends XhtmlObject {
   constructor(attributes) {
-    super(XHTML_NS_ID, "p");
-    this.style = checkStyle(attributes.style);
+    super(attributes, "p");
   }
 
 }
 
-class Span extends _xfa_object.XmlObject {
+class Span extends XhtmlObject {
   constructor(attributes) {
-    super(XHTML_NS_ID, "span");
-    this.style = checkStyle(attributes.style);
+    super(attributes, "span");
   }
 
 }
 
-class Sub extends _xfa_object.XmlObject {
+class Sub extends XhtmlObject {
   constructor(attributes) {
-    super(XHTML_NS_ID, "sub");
-    this.style = checkStyle(attributes.style);
+    super(attributes, "sub");
   }
 
 }
 
-class Sup extends _xfa_object.XmlObject {
+class Sup extends XhtmlObject {
   constructor(attributes) {
-    super(XHTML_NS_ID, "sup");
-    this.style = checkStyle(attributes.style);
+    super(attributes, "sup");
   }
 
 }
 
-class Ul extends _xfa_object.XmlObject {
+class Ul extends XhtmlObject {
   constructor(attributes) {
-    super(XHTML_NS_ID, "ul");
-    this.style = checkStyle(attributes.style);
+    super(attributes, "ul");
   }
 
 }
@@ -52619,7 +53421,7 @@ class XhtmlNamespace {
 exports.XhtmlNamespace = XhtmlNamespace;
 
 /***/ }),
-/* 68 */
+/* 69 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -52629,9 +53431,9 @@ Object.defineProperty(exports, "__esModule", ({
 }));
 exports.UnknownNamespace = void 0;
 
-var _namespaces = __w_pdfjs_require__(52);
+var _namespaces = __w_pdfjs_require__(53);
 
-var _xfa_object = __w_pdfjs_require__(50);
+var _xfa_object = __w_pdfjs_require__(51);
 
 class UnknownNamespace {
   constructor(nsId) {
@@ -52647,7 +53449,7 @@ class UnknownNamespace {
 exports.UnknownNamespace = UnknownNamespace;
 
 /***/ }),
-/* 69 */
+/* 70 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -53147,7 +53949,7 @@ class MessageHandler {
 exports.MessageHandler = MessageHandler;
 
 /***/ }),
-/* 70 */
+/* 71 */
 /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
 
 
@@ -53344,8 +54146,8 @@ Object.defineProperty(exports, "WorkerMessageHandler", ({
 
 var _worker = __w_pdfjs_require__(1);
 
-const pdfjsVersion = '2.8.320';
-const pdfjsBuild = 'ca7f54682';
+const pdfjsVersion = '2.9.44';
+const pdfjsBuild = '6cf307000';
 })();
 
 /******/ 	return __webpack_exports__;
diff --git a/toolkit/components/pdfjs/content/web/viewer.css b/toolkit/components/pdfjs/content/web/viewer.css
index f31438d90db0d..f9e506f6f5c80 100644
--- a/toolkit/components/pdfjs/content/web/viewer.css
+++ b/toolkit/components/pdfjs/content/web/viewer.css
@@ -24,7 +24,7 @@
   line-height: 1;
 }
 
-.textLayer > span {
+.textLayer span {
   color: transparent;
   position: absolute;
   white-space: pre;
@@ -269,20 +269,6 @@
   cursor: pointer;
 }
 
-*/* Copyright 2021 Mozilla Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
 
 .xfaLayer {
   position: absolute;
@@ -301,6 +287,7 @@
   text-decoration: inherit;
   vertical-align: inherit;
   box-sizing: border-box;
+  background: transparent;
 }
 
 .xfaFont {
@@ -315,19 +302,23 @@
 }
 
 .xfaDraw {
-  z-index: 200;
+  z-index: 100;
 }
 
 .xfaExclgroup {
-  z-index: 300;
+  z-index: 200;
 }
 
 .xfaField {
   z-index: 300;
 }
 
+.xfaRich {
+  z-index: 300;
+}
+
 .xfaSubform {
-  z-index: 100;
+  z-index: 200;
 }
 
 .xfaLabel {
@@ -348,6 +339,7 @@
   height: 100%;
   flex: 1 1 auto;
   border: none;
+  resize: none;
 }
 
 .xfaLabel > input[type="checkbox"] {
@@ -394,6 +386,16 @@
   background: Highlight;
 }
 
+.xfaRich {
+  white-space: pre-wrap;
+}
+
+.xfaImage,
+.xfaRich {
+  width: 100%;
+  height: 100%;
+}
+
 .xfaLrTb,
 .xfaRlTb,
 .xfaTb,
@@ -405,6 +407,10 @@
   position: relative;
 }
 
+.xfaArea {
+  position: relative;
+}
+
 .xfaValignMiddle {
   display: flex;
   align-items: center;
@@ -445,6 +451,26 @@
   flex: 1;
 }
 
+:root {
+  --pdfViewer-padding-bottom: none;
+  --page-margin: 1px auto -8px;
+  --page-border: 9px solid transparent;
+  --spreadHorizontalWrapped-margin-LR: -3.5px;
+}
+
+@media screen and (forced-colors: active) {
+  :root {
+    --pdfViewer-padding-bottom: 9px;
+    --page-margin: 9px auto 0;
+    --page-border: none;
+    --spreadHorizontalWrapped-margin-LR: 4.5px;
+  }
+}
+
+.pdfViewer {
+  padding-bottom: var(--pdfViewer-padding-bottom);
+}
+
 .pdfViewer .canvasWrapper {
   overflow: hidden;
 }
@@ -453,10 +479,10 @@
   direction: ltr;
   width: 816px;
   height: 1056px;
-  margin: 1px auto -8px;
+  margin: var(--page-margin);
   position: relative;
   overflow: visible;
-  border: 9px solid transparent;
+  border: var(--page-border);
   background-clip: content-box;
   border-image: url(images/shadow.png) 9 9 repeat;
   background-color: rgba(255, 255, 255, 1);
@@ -508,8 +534,8 @@
 .spread .page,
 .pdfViewer.scrollHorizontal .page,
 .pdfViewer.scrollWrapped .page {
-  margin-left: -3.5px;
-  margin-right: -3.5px;
+  margin-left: var(--spreadHorizontalWrapped-margin-LR);
+  margin-right: var(--spreadHorizontalWrapped-margin-LR);
 }
 
 .pdfViewer.removePageBorders .spread .page,
@@ -570,19 +596,21 @@
 
   --main-color: rgba(12, 12, 13, 1);
   --body-bg-color: rgba(237, 237, 240, 1);
-  --errorWrapper-bg-color: rgba(255, 74, 74, 1);
+  --errorWrapper-bg-color: rgba(255, 110, 110, 1);
   --progressBar-color: rgba(10, 132, 255, 1);
   --progressBar-indeterminate-bg-color: rgba(221, 221, 222, 1);
   --progressBar-indeterminate-blend-color: rgba(116, 177, 239, 1);
   --scrollbar-color: auto;
   --scrollbar-bg-color: auto;
   --toolbar-icon-bg-color: rgba(0, 0, 0, 1);
+  --toolbar-icon-hover-bg-color: rgba(0, 0, 0, 1);
 
   --sidebar-narrow-bg-color: rgba(237, 237, 240, 0.9);
   --sidebar-toolbar-bg-color: rgba(245, 246, 247, 1);
   --toolbar-bg-color: rgba(249, 249, 250, 1);
   --toolbar-border-color: rgba(204, 204, 204, 1);
   --button-hover-color: rgba(221, 222, 223, 1);
+  --toggled-btn-color: rgba(0, 0, 0, 1);
   --toggled-btn-bg-color: rgba(0, 0, 0, 0.3);
   --toggled-hover-active-btn-color: rgba(0, 0, 0, 0.4);
   --dropdown-btn-bg-color: rgba(215, 215, 219, 1);
@@ -598,10 +626,12 @@
   --sidebaritem-bg-color: rgba(0, 0, 0, 0.15);
   --doorhanger-bg-color: rgba(255, 255, 255, 1);
   --doorhanger-border-color: rgba(12, 12, 13, 0.2);
-  --doorhanger-hover-color: rgba(237, 237, 237, 1);
+  --doorhanger-hover-color: rgba(12, 12, 13, 1);
+  --doorhanger-hover-bg-color: rgba(237, 237, 237, 1);
   --doorhanger-separator-color: rgba(222, 222, 222, 1);
+  --overlay-button-border: 0 none;
   --overlay-button-bg-color: rgba(12, 12, 13, 0.1);
-  --overlay-button-hover-color: rgba(12, 12, 13, 0.3);
+  --overlay-button-hover-bg-color: rgba(12, 12, 13, 0.3);
 
   --loading-icon: url(images/loading.svg);
   --treeitem-expanded-icon: url(images/treeitem-expanded.svg);
@@ -645,19 +675,21 @@
   :root {
     --main-color: rgba(249, 249, 250, 1);
     --body-bg-color: rgba(42, 42, 46, 1);
-    --errorWrapper-bg-color: rgba(199, 17, 17, 1);
+    --errorWrapper-bg-color: rgba(169, 14, 14, 1);
     --progressBar-color: rgba(0, 96, 223, 1);
     --progressBar-indeterminate-bg-color: rgba(40, 40, 43, 1);
     --progressBar-indeterminate-blend-color: rgba(20, 68, 133, 1);
     --scrollbar-color: rgba(121, 121, 123, 1);
     --scrollbar-bg-color: rgba(35, 35, 39, 1);
     --toolbar-icon-bg-color: rgba(255, 255, 255, 1);
+    --toolbar-icon-hover-bg-color: rgba(255, 255, 255, 1);
 
     --sidebar-narrow-bg-color: rgba(42, 42, 46, 0.9);
     --sidebar-toolbar-bg-color: rgba(50, 50, 52, 1);
     --toolbar-bg-color: rgba(56, 56, 61, 1);
     --toolbar-border-color: rgba(12, 12, 13, 1);
     --button-hover-color: rgba(102, 102, 103, 1);
+    --toggled-btn-color: rgba(255, 255, 255, 1);
     --toggled-btn-bg-color: rgba(0, 0, 0, 0.3);
     --toggled-hover-active-btn-color: rgba(0, 0, 0, 0.4);
     --dropdown-btn-bg-color: rgba(74, 74, 79, 1);
@@ -673,10 +705,11 @@
     --sidebaritem-bg-color: rgba(255, 255, 255, 0.15);
     --doorhanger-bg-color: rgba(74, 74, 79, 1);
     --doorhanger-border-color: rgba(39, 39, 43, 1);
-    --doorhanger-hover-color: rgba(93, 94, 98, 1);
+    --doorhanger-hover-color: rgba(249, 249, 250, 1);
+    --doorhanger-hover-bg-color: rgba(93, 94, 98, 1);
     --doorhanger-separator-color: rgba(92, 92, 97, 1);
     --overlay-button-bg-color: rgba(92, 92, 97, 1);
-    --overlay-button-hover-color: rgba(115, 115, 115, 1);
+    --overlay-button-hover-bg-color: rgba(115, 115, 115, 1);
 
     /* This image is used in <input> elements, which unfortunately means that
      * the `mask-image` approach used with all of the other images doesn't work
@@ -685,6 +718,26 @@
   }
 }
 
+@media screen and (forced-colors: active) {
+  :root {
+    --main-color: ButtonText;
+    --button-hover-color: Highlight;
+    --doorhanger-hover-bg-color: Highlight;
+    --toolbar-icon-opacity: 1;
+    --toolbar-icon-bg-color: ButtonText;
+    --toolbar-icon-hover-bg-color: ButtonFace;
+    --toggled-btn-color: HighlightText;
+    --toggled-btn-bg-color: LinkText;
+    --doorhanger-hover-color: ButtonFace;
+    --doorhanger-border-color-whcm: 1px solid ButtonText;
+    --doorhanger-triangle-opacity-whcm: 0;
+    --overlay-button-border: 1px solid Highlight;
+    --overlay-button-hover-bg-color: Highlight;
+    --overlay-button-hover-color: ButtonFace;
+    --field-border-color: ButtonText;
+  }
+}
+
 * {
   padding: 0;
   margin: 0;
@@ -719,7 +772,7 @@ select {
   display: none !important;
 }
 
-.pdfViewer.enablePermissions .textLayer > span {
+.pdfViewer.enablePermissions .textLayer span {
   user-select: none !important;
   cursor: not-allowed;
 }
@@ -739,12 +792,12 @@ select {
   display: none;
 }
 
-.pdfPresentationMode:fullscreen .textLayer > span {
+.pdfPresentationMode:fullscreen .textLayer span {
   cursor: none;
 }
 
 .pdfPresentationMode.pdfPresentationModeControls > *,
-.pdfPresentationMode.pdfPresentationModeControls .textLayer > span {
+.pdfPresentationMode.pdfPresentationModeControls .textLayer span {
   cursor: default;
 }
 
@@ -768,10 +821,12 @@ select {
 html[dir="ltr"] #sidebarContainer {
   transition-property: left;
   left: calc(0px - var(--sidebar-width));
+  border-right: var(--doorhanger-border-color-whcm);
 }
 html[dir="rtl"] #sidebarContainer {
   transition-property: right;
   right: calc(0px - var(--sidebar-width));
+  border-left: var(--doorhanger-border-color-whcm);
 }
 
 #outerContainer.sidebarResizing #sidebarContainer {
@@ -1077,6 +1132,7 @@ html[dir="rtl"] .findbar .splitToolbarButton > .findNext {
 
 .findbar label:hover,
 .findbar input:focus + label {
+  color: var(--toggled-btn-color);
   background-color: var(--button-hover-color);
 }
 
@@ -1091,6 +1147,7 @@ html[dir="rtl"] #findInput {
 
 .findbar .toolbarField[type="checkbox"]:checked + .toolbarLabel {
   background-color: var(--toggled-btn-bg-color) !important;
+  color: var(--toggled-btn-color);
 }
 
 #findInput {
@@ -1141,6 +1198,7 @@ html[dir="rtl"] .secondaryToolbar {
   border-radius: 2px;
   box-shadow: 0 1px 5px var(--doorhanger-border-color),
     0 0 0 1px var(--doorhanger-border-color);
+  border: var(--doorhanger-border-color-whcm);
 }
 .doorHanger:after,
 .doorHanger:before,
@@ -1153,6 +1211,7 @@ html[dir="rtl"] .secondaryToolbar {
   width: 0;
   position: absolute;
   pointer-events: none;
+  opacity: var(--doorhanger-triangle-opacity-whcm);
 }
 .doorHanger:after,
 .doorHangerRight:after {
@@ -1198,7 +1257,7 @@ html[dir="ltr"] .doorHangerRight:before {
   background-color: rgba(217, 217, 217, 1);
   color: rgba(82, 82, 82, 1);
   text-align: center;
-  padding: 3px 4px;
+  padding: 4px 5px;
   margin: 5px;
 }
 
@@ -1265,13 +1324,15 @@ html[dir="rtl"] .splitToolbarButton > .toolbarButton {
   width: 28px;
   height: 28px;
 }
-.overlayButton {
-  background-color: var(--overlay-button-bg-color);
-}
 
 .overlayButton:hover,
 .overlayButton:focus {
-  background-color: var(--overlay-button-hover-color);
+  background-color: var(--overlay-button-hover-bg-color);
+}
+
+.overlayButton:hover > span,
+.overlayButton:focus > span {
+  color: var(--overlay-button-hover-color);
 }
 
 .toolbarButton > span {
@@ -1364,13 +1425,23 @@ html[dir="rtl"] #toolbarViewerLeft > .toolbarButton:first-child {
 }
 .secondaryToolbarButton:hover,
 .secondaryToolbarButton:focus {
-  background-color: var(--doorhanger-hover-color);
+  background-color: var(--doorhanger-hover-bg-color);
+  color: var(--doorhanger-hover-color);
 }
 
 .toolbarButton.toggled,
 .splitToolbarButton.toggled > .toolbarButton.toggled,
 .secondaryToolbarButton.toggled {
   background-color: var(--toggled-btn-bg-color);
+  color: var(--toggled-btn-color);
+}
+
+.secondaryToolbarButton.toggled::before {
+  background-color: var(--toggled-btn-color);
+}
+
+.toolbarButton.toggled::before {
+  background-color: var(--toggled-btn-color);
 }
 
 .toolbarButton.toggled:hover:active,
@@ -1415,16 +1486,15 @@ html[dir="ltr"] .dropdownToolbarButton > select {
 html[dir="rtl"] .dropdownToolbarButton > select {
   padding-right: 4px;
 }
-.dropdownToolbarButton > select:hover {
-  background-color: var(--button-hover-color);
-}
-
+.dropdownToolbarButton > select:hover,
 .dropdownToolbarButton > select:focus {
   background-color: var(--button-hover-color);
+  color: var(--toggled-btn-color);
 }
 
 .dropdownToolbarButton > select > option {
   background: var(--doorhanger-bg-color);
+  color: var(--main-color);
 }
 
 #customScaleOption {
@@ -1457,12 +1527,25 @@ html[dir="rtl"] .dropdownToolbarButton > select {
   mask-size: cover;
 }
 
+.dropdownToolbarButton:hover::after,
+.dropdownToolbarButton:focus::after,
+.dropdownToolbarButton:active::after {
+  background-color: var(--toolbar-icon-hover-bg-color);
+}
+
 .toolbarButton::before {
   opacity: var(--toolbar-icon-opacity);
   top: 6px;
   left: 6px;
 }
 
+.toolbarButton:hover::before,
+.toolbarButton:focus::before,
+.secondaryToolbarButton:hover::before,
+.secondaryToolbarButton:focus::before {
+  background-color: var(--toolbar-icon-hover-bg-color);
+}
+
 .secondaryToolbarButton::before {
   opacity: var(--doorhanger-icon-opacity);
   top: 5px;
@@ -1746,9 +1829,8 @@ html[dir="rtl"] .toolbarField[type="checkbox"] {
 
 .toolbarLabel {
   min-width: 16px;
-  padding: 6px;
+  padding: 7px;
   margin: 2px;
-  border: 1px solid rgba(0, 0, 0, 0);
   border-radius: 2px;
   color: var(--main-color);
   font-size: 12px;
@@ -1759,10 +1841,10 @@ html[dir="rtl"] .toolbarField[type="checkbox"] {
 }
 
 html[dir="ltr"] #numPages.toolbarLabel {
-  padding-left: 2px;
+  padding-left: 3px;
 }
 html[dir="rtl"] #numPages.toolbarLabel {
-  padding-right: 2px;
+  padding-right: 3px;
 }
 
 #thumbnailView {
@@ -1977,6 +2059,9 @@ html[dir="rtl"] .treeItemToggler::before {
   width: auto;
   margin: 3px 4px 2px !important;
   padding: 2px 11px;
+  color: var(--main-color);
+  background-color: var(--overlay-button-bg-color);
+  border: var(--overlay-button-border) !important;
 }
 
 #overlayContainer {
@@ -2145,19 +2230,19 @@ html[dir="rtl"] #documentPropertiesOverlay .row > * {
   mix-blend-mode: screen;
 }
 
-#viewer.textLayer-visible .textLayer > span {
+#viewer.textLayer-visible .textLayer span {
   background-color: rgba(255, 255, 0, 0.1);
   color: rgba(0, 0, 0, 1);
   border: solid 1px rgba(255, 0, 0, 0.5);
   box-sizing: border-box;
 }
 
-#viewer.textLayer-hover .textLayer > span:hover {
+#viewer.textLayer-hover .textLayer span:hover {
   background-color: rgba(255, 255, 255, 1);
   color: rgba(0, 0, 0, 1);
 }
 
-#viewer.textLayer-shadow .textLayer > span {
+#viewer.textLayer-shadow .textLayer span {
   background-color: rgba(255, 255, 255, 0.6);
   color: rgba(0, 0, 0, 1);
 }
diff --git a/toolkit/components/pdfjs/content/web/viewer.js b/toolkit/components/pdfjs/content/web/viewer.js
index 9729eed4e8b3d..71864476787ac 100644
--- a/toolkit/components/pdfjs/content/web/viewer.js
+++ b/toolkit/components/pdfjs/content/web/viewer.js
@@ -351,13 +351,13 @@ var _pdf_thumbnail_viewer = __webpack_require__(25);
 
 var _pdf_viewer = __webpack_require__(27);
 
-var _secondary_toolbar = __webpack_require__(34);
+var _secondary_toolbar = __webpack_require__(35);
 
-var _toolbar = __webpack_require__(36);
+var _toolbar = __webpack_require__(37);
 
 var _viewer_compatibility = __webpack_require__(2);
 
-var _view_history = __webpack_require__(37);
+var _view_history = __webpack_require__(38);
 
 const DEFAULT_SCALE_DELTA = 1.1;
 const DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
@@ -433,7 +433,7 @@ exports.DefaultExternalServices = DefaultExternalServices;
 const PDFViewerApplication = {
   initialBookmark: document.location.hash.substring(1),
   _initializedCapability: (0, _pdfjsLib.createPromiseCapability)(),
-  fellback: false,
+  _fellback: false,
   appConfig: null,
   pdfDocument: null,
   pdfLoadingTask: null,
@@ -640,7 +640,7 @@ const PDFViewerApplication = {
     this.eventBus = eventBus;
     this.overlayManager = new _overlay_manager.OverlayManager();
     const pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
-    pdfRenderingQueue.onIdle = this.cleanup.bind(this);
+    pdfRenderingQueue.onIdle = this._cleanup.bind(this);
     this.pdfRenderingQueue = pdfRenderingQueue;
     const pdfLinkService = new _pdf_link_service.PDFLinkService({
       eventBus,
@@ -919,7 +919,7 @@ const PDFViewerApplication = {
     this._unblockDocumentLoadEvent();
 
     if (!this.pdfLoadingTask) {
-      return undefined;
+      return;
     }
 
     const promises = [];
@@ -935,6 +935,7 @@ const PDFViewerApplication = {
     }
 
     webViewerResetPermissions();
+    this._fellback = false;
     this.store = null;
     this.isInitialViewSet = false;
     this.downloadComplete = false;
@@ -971,7 +972,6 @@ const PDFViewerApplication = {
     }
 
     await Promise.all(promises);
-    return undefined;
   },
 
   async open(file, args) {
@@ -1059,28 +1059,31 @@ const PDFViewerApplication = {
     });
   },
 
-  download({
-    sourceEventType = "download"
-  } = {}) {
-    function downloadByUrl() {
-      downloadManager.downloadUrl(url, filename);
+  _ensureDownloadComplete() {
+    if (this.pdfDocument && this.downloadComplete) {
+      return;
     }
 
-    const downloadManager = this.downloadManager,
-          url = this.baseUrl,
+    throw new Error("PDF document not downloaded.");
+  },
+
+  async download({
+    sourceEventType = "download"
+  } = {}) {
+    const url = this.baseUrl,
           filename = this._docFilename;
 
-    if (!this.pdfDocument || !this.downloadComplete) {
-      downloadByUrl();
-      return;
-    }
+    try {
+      this._ensureDownloadComplete();
 
-    this.pdfDocument.getData().then(function (data) {
+      const data = await this.pdfDocument.getData();
       const blob = new Blob([data], {
         type: "application/pdf"
       });
-      downloadManager.download(blob, url, filename, sourceEventType);
-    }).catch(downloadByUrl);
+      await this.downloadManager.download(blob, url, filename, sourceEventType);
+    } catch (reason) {
+      await this.downloadManager.downloadUrl(url, filename);
+    }
   },
 
   async save({
@@ -1090,32 +1093,27 @@ const PDFViewerApplication = {
       return;
     }
 
-    const downloadManager = this.downloadManager,
-          url = this.baseUrl,
+    this._saveInProgress = true;
+    await this.pdfScriptingManager.dispatchWillSave();
+    const url = this.baseUrl,
           filename = this._docFilename;
 
-    if (!this.pdfDocument || !this.downloadComplete) {
-      this.download({
-        sourceEventType
-      });
-      return;
-    }
+    try {
+      this._ensureDownloadComplete();
 
-    this._saveInProgress = true;
-    await this.pdfScriptingManager.dispatchWillSave();
-    this.pdfDocument.saveDocument(this.pdfDocument.annotationStorage).then(data => {
+      const data = await this.pdfDocument.saveDocument();
       const blob = new Blob([data], {
         type: "application/pdf"
       });
-      downloadManager.download(blob, url, filename, sourceEventType);
-    }).catch(() => {
-      this.download({
+      await this.downloadManager.download(blob, url, filename, sourceEventType);
+    } catch (reason) {
+      await this.download({
         sourceEventType
       });
-    }).finally(async () => {
+    } finally {
       await this.pdfScriptingManager.dispatchDidSave();
       this._saveInProgress = false;
-    });
+    }
   },
 
   downloadOrSave(options) {
@@ -1152,11 +1150,11 @@ const PDFViewerApplication = {
         return;
     }
 
-    if (this.fellback) {
+    if (this._fellback) {
       return;
     }
 
-    this.fellback = true;
+    this._fellback = true;
     this.externalServices.fallback({
       featureId,
       url: this.baseUrl
@@ -1379,17 +1377,29 @@ const PDFViewerApplication = {
     });
     onePageRendered.then(() => {
       pdfDocument.getOutline().then(outline => {
+        if (pdfDocument !== this.pdfDocument) {
+          return;
+        }
+
         this.pdfOutlineViewer.render({
           outline,
           pdfDocument
         });
       });
       pdfDocument.getAttachments().then(attachments => {
+        if (pdfDocument !== this.pdfDocument) {
+          return;
+        }
+
         this.pdfAttachmentViewer.render({
           attachments
         });
       });
       pdfViewer.optionalContentConfigPromise.then(optionalContentConfig => {
+        if (pdfDocument !== this.pdfDocument) {
+          return;
+        }
+
         this.pdfLayerViewer.render({
           optionalContentConfig,
           pdfDocument
@@ -1544,6 +1554,11 @@ const PDFViewerApplication = {
       this._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
     }
 
+    if (info.IsSignaturesPresent) {
+      console.warn("Warning: Digital signatures validation is not supported");
+      this.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.signatures);
+    }
+
     let versionId = "other";
 
     if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) {
@@ -1676,11 +1691,11 @@ const PDFViewerApplication = {
       annotationStorage
     } = pdfDocument;
 
-    annotationStorage.onSetModified = function () {
+    annotationStorage.onSetModified = () => {
       window.addEventListener("beforeunload", beforeUnload);
     };
 
-    annotationStorage.onResetModified = function () {
+    annotationStorage.onResetModified = () => {
       window.removeEventListener("beforeunload", beforeUnload);
     };
   },
@@ -1729,17 +1744,14 @@ const PDFViewerApplication = {
     }
   },
 
-  cleanup() {
+  _cleanup() {
     if (!this.pdfDocument) {
       return;
     }
 
     this.pdfViewer.cleanup();
     this.pdfThumbnailViewer.cleanup();
-
-    if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
-      this.pdfDocument.cleanup();
-    }
+    this.pdfDocument.cleanup(this.pdfViewer.renderer === _ui_utils.RendererType.SVG);
   },
 
   forceRendering() {
@@ -5339,7 +5351,7 @@ class PDFFindController {
     this._pageDiffs = [];
     this._matchesCountTotal = 0;
     this._pagesToSearch = null;
-    this._pendingFindMatches = Object.create(null);
+    this._pendingFindMatches = new Set();
     this._resumePageIdx = null;
     this._dirtyMatch = false;
     clearTimeout(this._findTimeout);
@@ -5629,14 +5641,14 @@ class PDFFindController {
       this._updateAllPages();
 
       for (let i = 0; i < numPages; i++) {
-        if (this._pendingFindMatches[i] === true) {
+        if (this._pendingFindMatches.has(i)) {
           continue;
         }
 
-        this._pendingFindMatches[i] = true;
+        this._pendingFindMatches.add(i);
 
         this._extractTextPromises[i].then(pageIdx => {
-          delete this._pendingFindMatches[pageIdx];
+          this._pendingFindMatches.delete(pageIdx);
 
           this._calculateMatch(pageIdx);
         });
@@ -6790,11 +6802,6 @@ class PDFLinkService {
     this.pdfViewer.pagesRotation = value;
   }
 
-  navigateTo(dest) {
-    console.error("Deprecated method: `navigateTo`, use `goToDestination` instead.");
-    this.goToDestination(dest);
-  }
-
   _goToDestinationHelper(rawDest, namedDest = null, explicitDest) {
     const destRef = explicitDest[0];
     let pageNumber;
@@ -7223,6 +7230,10 @@ class PDFOutlineViewer extends _base_tree_viewer.BaseTreeViewer {
 
     this.eventBus._on("pagesloaded", evt => {
       this._isPagesLoaded = !!evt.pagesCount;
+
+      if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) {
+        this._currentOutlineItemCapability.resolve(this._isPagesLoaded);
+      }
     });
 
     this.eventBus._on("sidebarviewchanged", evt => {
@@ -7236,13 +7247,27 @@ class PDFOutlineViewer extends _base_tree_viewer.BaseTreeViewer {
     this._pageNumberToDestHashCapability = null;
     this._currentPageNumber = 1;
     this._isPagesLoaded = false;
+
+    if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) {
+      this._currentOutlineItemCapability.resolve(false);
+    }
+
+    this._currentOutlineItemCapability = null;
   }
 
   _dispatchEvent(outlineCount) {
+    this._currentOutlineItemCapability = (0, _pdfjsLib.createPromiseCapability)();
+
+    if (outlineCount === 0 || this._pdfDocument?.loadingParams.disableAutoFetch) {
+      this._currentOutlineItemCapability.resolve(false);
+    } else if (this._isPagesLoaded) {
+      this._currentOutlineItemCapability.resolve(true);
+    }
+
     this.eventBus.dispatch("outlineloaded", {
       source: this,
       outlineCount,
-      enableCurrentOutlineItemButton: outlineCount > 0 && !this._pdfDocument?.loadingParams.disableAutoFetch
+      currentOutlineItemPromise: this._currentOutlineItemCapability.promise
     });
   }
 
@@ -8635,12 +8660,13 @@ class PDFSidebar {
 
     this.eventBus._on("outlineloaded", evt => {
       onTreeLoaded(evt.outlineCount, this.outlineButton, _ui_utils.SidebarView.OUTLINE);
+      evt.currentOutlineItemPromise.then(enabled => {
+        if (!this.isInitialViewSet) {
+          return;
+        }
 
-      if (evt.enableCurrentOutlineItemButton) {
-        this.pdfViewer.pagesPromise.then(() => {
-          this._currentOutlineItemButton.disabled = !this.isInitialViewSet;
-        });
-      }
+        this._currentOutlineItemButton.disabled = !enabled;
+      });
     });
 
     this.eventBus._on("attachmentsloaded", evt => {
@@ -9091,6 +9117,7 @@ var _pdfjsLib = __webpack_require__(5);
 
 var _pdf_rendering_queue = __webpack_require__(8);
 
+const DRAW_UPSCALE_FACTOR = 2;
 const MAX_NUM_SCALING_STEPS = 3;
 const THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
 const THUMBNAIL_WIDTH = 98;
@@ -9116,7 +9143,7 @@ const TempImageFactory = function TempImageFactoryClosure() {
       ctx.fillStyle = "rgb(255, 255, 255)";
       ctx.fillRect(0, 0, width, height);
       ctx.restore();
-      return tempCanvas;
+      return [tempCanvas, tempCanvas.getContext("2d")];
     },
 
     destroyCanvas() {
@@ -9166,12 +9193,12 @@ class PDFThumbnailView {
     };
 
     this.disableCanvasToImageConversion = disableCanvasToImageConversion;
-    this.pageWidth = this.viewport.width;
-    this.pageHeight = this.viewport.height;
-    this.pageRatio = this.pageWidth / this.pageHeight;
+    const pageWidth = this.viewport.width,
+          pageHeight = this.viewport.height,
+          pageRatio = pageWidth / pageHeight;
     this.canvasWidth = THUMBNAIL_WIDTH;
-    this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
-    this.scale = this.canvasWidth / this.pageWidth;
+    this.canvasHeight = this.canvasWidth / pageRatio | 0;
+    this.scale = this.canvasWidth / pageWidth;
     this.l10n = l10n;
     const anchor = document.createElement("a");
     anchor.href = linkService.getAnchorUrl("#page=" + id);
@@ -9215,19 +9242,14 @@ class PDFThumbnailView {
   reset() {
     this.cancelRendering();
     this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
-    this.pageWidth = this.viewport.width;
-    this.pageHeight = this.viewport.height;
-    this.pageRatio = this.pageWidth / this.pageHeight;
-    this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
-    this.scale = this.canvasWidth / this.pageWidth;
+    const pageWidth = this.viewport.width,
+          pageHeight = this.viewport.height,
+          pageRatio = pageWidth / pageHeight;
+    this.canvasHeight = this.canvasWidth / pageRatio | 0;
+    this.scale = this.canvasWidth / pageWidth;
     this.div.removeAttribute("data-loaded");
     const ring = this.ring;
-    const childNodes = ring.childNodes;
-
-    for (let i = childNodes.length - 1; i >= 0; i--) {
-      ring.removeChild(childNodes[i]);
-    }
-
+    ring.textContent = "";
     const borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
     ring.style.width = this.canvasWidth + borderAdjustment + "px";
     ring.style.height = this.canvasHeight + borderAdjustment + "px";
@@ -9266,47 +9288,47 @@ class PDFThumbnailView {
     this.resume = null;
   }
 
-  _getPageDrawContext() {
+  _getPageDrawContext(upscaleFactor = 1) {
     const canvas = document.createElement("canvas");
-    this.canvas = canvas;
     canvas.mozOpaque = true;
     const ctx = canvas.getContext("2d", {
       alpha: false
     });
     const outputScale = (0, _ui_utils.getOutputScale)(ctx);
-    canvas.width = this.canvasWidth * outputScale.sx | 0;
-    canvas.height = this.canvasHeight * outputScale.sy | 0;
-    canvas.style.width = this.canvasWidth + "px";
-    canvas.style.height = this.canvasHeight + "px";
+    canvas.width = upscaleFactor * this.canvasWidth * outputScale.sx | 0;
+    canvas.height = upscaleFactor * this.canvasHeight * outputScale.sy | 0;
     const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
-    return [ctx, transform];
+    return {
+      ctx,
+      canvas,
+      transform
+    };
   }
 
-  _convertCanvasToImage() {
-    if (!this.canvas) {
-      return;
-    }
-
+  _convertCanvasToImage(canvas) {
     if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
-      return;
+      throw new Error("_convertCanvasToImage: Rendering has not finished.");
     }
 
-    const className = "thumbnailImage";
+    const reducedCanvas = this._reduceImage(canvas);
 
     if (this.disableCanvasToImageConversion) {
-      this.canvas.className = className;
+      reducedCanvas.className = "thumbnailImage";
 
       this._thumbPageCanvas.then(msg => {
-        this.canvas.setAttribute("aria-label", msg);
+        reducedCanvas.setAttribute("aria-label", msg);
       });
 
+      reducedCanvas.style.width = this.canvasWidth + "px";
+      reducedCanvas.style.height = this.canvasHeight + "px";
+      this.canvas = reducedCanvas;
       this.div.setAttribute("data-loaded", true);
-      this.ring.appendChild(this.canvas);
+      this.ring.appendChild(reducedCanvas);
       return;
     }
 
     const image = document.createElement("img");
-    image.className = className;
+    image.className = "thumbnailImage";
 
     this._thumbPageCanvas.then(msg => {
       image.setAttribute("aria-label", msg);
@@ -9314,13 +9336,12 @@ class PDFThumbnailView {
 
     image.style.width = this.canvasWidth + "px";
     image.style.height = this.canvasHeight + "px";
-    image.src = this.canvas.toDataURL();
+    image.src = reducedCanvas.toDataURL();
     this.image = image;
     this.div.setAttribute("data-loaded", true);
     this.ring.appendChild(image);
-    this.canvas.width = 0;
-    this.canvas.height = 0;
-    delete this.canvas;
+    reducedCanvas.width = 0;
+    reducedCanvas.height = 0;
   }
 
   draw() {
@@ -9351,17 +9372,21 @@ class PDFThumbnailView {
 
       this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
 
-      this._convertCanvasToImage();
+      this._convertCanvasToImage(canvas);
 
       if (error) {
         throw error;
       }
     };
 
-    const [ctx, transform] = this._getPageDrawContext();
+    const {
+      ctx,
+      canvas,
+      transform
+    } = this._getPageDrawContext(DRAW_UPSCALE_FACTOR);
 
     const drawViewport = this.viewport.clone({
-      scale: this.scale
+      scale: DRAW_UPSCALE_FACTOR * this.scale
     });
 
     const renderContinueCallback = cont => {
@@ -9388,18 +9413,18 @@ class PDFThumbnailView {
     const renderTask = this.renderTask = pdfPage.render(renderContext);
     renderTask.onContinue = renderContinueCallback;
     const resultPromise = renderTask.promise.then(function () {
-      finishRenderTask(null);
+      return finishRenderTask(null);
     }, function (error) {
-      finishRenderTask(error);
+      return finishRenderTask(error);
     });
     resultPromise.finally(() => {
+      canvas.width = 0;
+      canvas.height = 0;
       const pageCached = this.linkService.isPageCached(this.id);
 
-      if (pageCached) {
-        return;
+      if (!pageCached) {
+        this.pdfPage?.cleanup();
       }
-
-      this.pdfPage?.cleanup();
     });
     return resultPromise;
   }
@@ -9413,34 +9438,38 @@ class PDFThumbnailView {
       return;
     }
 
-    const img = pageView.canvas;
+    const {
+      canvas,
+      pdfPage
+    } = pageView;
 
-    if (!img) {
+    if (!canvas) {
       return;
     }
 
     if (!this.pdfPage) {
-      this.setPdfPage(pageView.pdfPage);
+      this.setPdfPage(pdfPage);
     }
 
     this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
 
-    const [ctx] = this._getPageDrawContext();
+    this._convertCanvasToImage(canvas);
+  }
 
-    const canvas = ctx.canvas;
+  _reduceImage(img) {
+    const {
+      ctx,
+      canvas
+    } = this._getPageDrawContext();
 
     if (img.width <= 2 * canvas.width) {
       ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
-
-      this._convertCanvasToImage();
-
-      return;
+      return canvas;
     }
 
     let reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
     let reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
-    const reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
-    const reducedImageCtx = reducedImage.getContext("2d");
+    const [reducedImage, reducedImageCtx] = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
 
     while (reducedWidth > img.width || reducedHeight > img.height) {
       reducedWidth >>= 1;
@@ -9456,8 +9485,7 @@ class PDFThumbnailView {
     }
 
     ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
-
-    this._convertCanvasToImage();
+    return canvas;
   }
 
   get _thumbPageTitle() {
@@ -9486,7 +9514,7 @@ class PDFThumbnailView {
     this._thumbPageCanvas.then(msg => {
       if (this.image) {
         this.image.setAttribute("aria-label", msg);
-      } else if (this.disableCanvasToImageConversion && this.canvas) {
+      } else if (this.canvas) {
         this.canvas.setAttribute("aria-label", msg);
       }
     });
@@ -9609,9 +9637,11 @@ var _pdf_page_view = __webpack_require__(31);
 
 var _pdf_link_service = __webpack_require__(19);
 
-var _text_layer_builder = __webpack_require__(32);
+var _struct_tree_layer_builder = __webpack_require__(32);
 
-var _xfa_layer_builder = __webpack_require__(33);
+var _text_layer_builder = __webpack_require__(33);
+
+var _xfa_layer_builder = __webpack_require__(34);
 
 const DEFAULT_CACHE_SIZE = 10;
 
@@ -9675,7 +9705,7 @@ class BaseViewer {
       throw new Error("Cannot initialize BaseViewer.");
     }
 
-    const viewerVersion = '2.8.320';
+    const viewerVersion = '2.9.44';
 
     if (_pdfjsLib.version !== viewerVersion) {
       throw new Error(`The API version "${_pdfjsLib.version}" does not match the Viewer version "${viewerVersion}".`);
@@ -10000,14 +10030,14 @@ class BaseViewer {
           textLayerMode: this.textLayerMode,
           annotationLayerFactory: this,
           xfaLayerFactory,
+          structTreeLayerFactory: this,
           imageResourcesPath: this.imageResourcesPath,
           renderInteractiveForms: this.renderInteractiveForms,
           renderer: this.renderer,
           enableWebGL: this.enableWebGL,
           useOnlyCssZoom: this.useOnlyCssZoom,
           maxCanvasPixels: this.maxCanvasPixels,
-          l10n: this.l10n,
-          enableScripting: this.enableScripting
+          l10n: this.l10n
         });
 
         this._pages.push(pageView);
@@ -10635,7 +10665,7 @@ class BaseViewer {
     });
   }
 
-  createAnnotationLayerBuilder(pageDiv, pdfPage, annotationStorage = null, imageResourcesPath = "", renderInteractiveForms = false, l10n = _l10n_utils.NullL10n, enableScripting = false, hasJSActionsPromise = null, mouseState = null) {
+  createAnnotationLayerBuilder(pageDiv, pdfPage, annotationStorage = null, imageResourcesPath = "", renderInteractiveForms = false, l10n = _l10n_utils.NullL10n, enableScripting = null, hasJSActionsPromise = null, mouseState = null) {
     return new _annotation_layer_builder.AnnotationLayerBuilder({
       pageDiv,
       pdfPage,
@@ -10645,7 +10675,7 @@ class BaseViewer {
       linkService: this.linkService,
       downloadManager: this.downloadManager,
       l10n,
-      enableScripting,
+      enableScripting: enableScripting ?? this.enableScripting,
       hasJSActionsPromise: hasJSActionsPromise || this.pdfDocument?.hasJSActions(),
       mouseState: mouseState || this._scriptingManager?.mouseState
     });
@@ -10658,6 +10688,12 @@ class BaseViewer {
     });
   }
 
+  createStructTreeLayerBuilder(pdfPage) {
+    return new _struct_tree_layer_builder.StructTreeLayerBuilder({
+      pdfPage
+    });
+  }
+
   get hasEqualPageSizes() {
     const firstPageView = this._pages[0];
 
@@ -11187,7 +11223,8 @@ const DEFAULT_L10N_STRINGS = {
   unexpected_response_error: "Unexpected server response.",
   printing_not_supported: "Warning: Printing is not fully supported by this browser.",
   printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
-  web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts."
+  web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts.",
+  unsupported_feature_signatures: "This PDF document contains digital signatures. Validation of signatures is not supported."
 };
 
 function getL10nFallback(key, args) {
@@ -11279,10 +11316,10 @@ class PDFPageView {
     this.textLayerFactory = options.textLayerFactory;
     this.annotationLayerFactory = options.annotationLayerFactory;
     this.xfaLayerFactory = options.xfaLayerFactory;
+    this.structTreeLayerFactory = options.structTreeLayerFactory;
     this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
     this.enableWebGL = options.enableWebGL || false;
     this.l10n = options.l10n || _l10n_utils.NullL10n;
-    this.enableScripting = options.enableScripting === true;
     this.paintTask = null;
     this.paintedViewportMap = new WeakMap();
     this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
@@ -11292,6 +11329,7 @@ class PDFPageView {
     this.textLayer = null;
     this.zoomLayer = null;
     this.xfaLayer = null;
+    this.structTreeLayer = null;
     const div = document.createElement("div");
     div.className = "page";
     div.style.width = Math.floor(this.viewport.width) + "px";
@@ -11512,6 +11550,12 @@ class PDFPageView {
       this.annotationLayer.cancel();
       this.annotationLayer = null;
     }
+
+    if (this._onTextLayerRendered) {
+      this.eventBus._off("textlayerrendered", this._onTextLayerRendered);
+
+      this._onTextLayerRendered = null;
+    }
   }
 
   cssTransform(target, redrawAnnotations = false) {
@@ -11702,11 +11746,12 @@ class PDFPageView {
     const paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
     paintTask.onRenderContinue = renderContinueCallback;
     this.paintTask = paintTask;
-    const resultPromise = paintTask.promise.then(function () {
-      return finishPaintTask(null).then(function () {
+    const resultPromise = paintTask.promise.then(() => {
+      return finishPaintTask(null).then(() => {
         if (textLayer) {
           const readableStream = pdfPage.streamTextContent({
-            normalizeWhitespace: true
+            normalizeWhitespace: true,
+            includeMarkedContent: true
           });
           textLayer.setTextContentStream(readableStream);
           textLayer.render();
@@ -11718,7 +11763,7 @@ class PDFPageView {
 
     if (this.annotationLayerFactory) {
       if (!this.annotationLayer) {
-        this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, null, this.imageResourcesPath, this.renderInteractiveForms, this.l10n, this.enableScripting, null, null);
+        this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, null, this.imageResourcesPath, this.renderInteractiveForms, this.l10n, null, null, null);
       }
 
       this._renderAnnotationLayer();
@@ -11732,6 +11777,31 @@ class PDFPageView {
       this._renderXfaLayer();
     }
 
+    if (this.structTreeLayerFactory && this.textLayer && this.canvas) {
+      this._onTextLayerRendered = event => {
+        if (event.pageNumber !== this.id) {
+          return;
+        }
+
+        this.eventBus._off("textlayerrendered", this._onTextLayerRendered);
+
+        this._onTextLayerRendered = null;
+        this.pdfPage.getStructTree().then(tree => {
+          if (!tree) {
+            return;
+          }
+
+          const treeDom = this.structTreeLayer.render(tree);
+          treeDom.classList.add("structTree");
+          this.canvas.appendChild(treeDom);
+        });
+      };
+
+      this.eventBus._on("textlayerrendered", this._onTextLayerRendered);
+
+      this.structTreeLayer = this.structTreeLayerFactory.createStructTreeLayerBuilder(pdfPage);
+    }
+
     div.setAttribute("data-loaded", true);
     this.eventBus.dispatch("pagerender", {
       source: this,
@@ -11863,6 +11933,132 @@ exports.PDFPageView = PDFPageView;
 
 /***/ }),
 /* 32 */
+/***/ ((__unused_webpack_module, exports) => {
+
+
+
+Object.defineProperty(exports, "__esModule", ({
+  value: true
+}));
+exports.StructTreeLayerBuilder = exports.DefaultStructTreeLayerFactory = void 0;
+const PDF_ROLE_TO_HTML_ROLE = {
+  Document: null,
+  DocumentFragment: null,
+  Part: "group",
+  Sect: "group",
+  Div: "group",
+  Aside: "note",
+  NonStruct: "none",
+  P: null,
+  H: "heading",
+  Title: null,
+  FENote: "note",
+  Sub: "group",
+  Lbl: null,
+  Span: null,
+  Em: null,
+  Strong: null,
+  Link: "link",
+  Annot: "note",
+  Form: "form",
+  Ruby: null,
+  RB: null,
+  RT: null,
+  RP: null,
+  Warichu: null,
+  WT: null,
+  WP: null,
+  L: "list",
+  LI: "listitem",
+  LBody: null,
+  Table: "table",
+  TR: "row",
+  TH: "columnheader",
+  TD: "cell",
+  THead: "columnheader",
+  TBody: null,
+  TFoot: null,
+  Caption: null,
+  Figure: "figure",
+  Formula: null,
+  Artifact: null
+};
+const HEADING_PATTERN = /^H(\d+)$/;
+
+class StructTreeLayerBuilder {
+  constructor({
+    pdfPage
+  }) {
+    this.pdfPage = pdfPage;
+  }
+
+  render(structTree) {
+    return this._walk(structTree);
+  }
+
+  _setAttributes(structElement, htmlElement) {
+    if (structElement.alt !== undefined) {
+      htmlElement.setAttribute("aria-label", structElement.alt);
+    }
+
+    if (structElement.id !== undefined) {
+      htmlElement.setAttribute("aria-owns", structElement.id);
+    }
+  }
+
+  _walk(node) {
+    if (!node) {
+      return null;
+    }
+
+    const element = document.createElement("span");
+
+    if ("role" in node) {
+      const {
+        role
+      } = node;
+      const match = role.match(HEADING_PATTERN);
+
+      if (match) {
+        element.setAttribute("role", "heading");
+        element.setAttribute("aria-level", match[1]);
+      } else if (PDF_ROLE_TO_HTML_ROLE[role]) {
+        element.setAttribute("role", PDF_ROLE_TO_HTML_ROLE[role]);
+      }
+    }
+
+    this._setAttributes(node, element);
+
+    if (node.children) {
+      if (node.children.length === 1 && "id" in node.children[0]) {
+        this._setAttributes(node.children[0], element);
+      } else {
+        for (const kid of node.children) {
+          element.appendChild(this._walk(kid));
+        }
+      }
+    }
+
+    return element;
+  }
+
+}
+
+exports.StructTreeLayerBuilder = StructTreeLayerBuilder;
+
+class DefaultStructTreeLayerFactory {
+  createStructTreeLayerBuilder(pdfPage) {
+    return new StructTreeLayerBuilder({
+      pdfPage
+    });
+  }
+
+}
+
+exports.DefaultStructTreeLayerFactory = DefaultStructTreeLayerFactory;
+
+/***/ }),
+/* 33 */
 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
 
 
@@ -12216,7 +12412,7 @@ class DefaultTextLayerFactory {
 exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
 
 /***/ }),
-/* 33 */
+/* 34 */
 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
 
 
@@ -12295,7 +12491,7 @@ class DefaultXfaLayerFactory {
 exports.DefaultXfaLayerFactory = DefaultXfaLayerFactory;
 
 /***/ }),
-/* 34 */
+/* 35 */
 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
 
 
@@ -12309,7 +12505,7 @@ var _ui_utils = __webpack_require__(4);
 
 var _pdf_cursor_tools = __webpack_require__(6);
 
-var _pdf_single_page_viewer = __webpack_require__(35);
+var _pdf_single_page_viewer = __webpack_require__(36);
 
 class SecondaryToolbar {
   constructor(options, mainContainer, eventBus) {
@@ -12614,7 +12810,7 @@ class SecondaryToolbar {
 exports.SecondaryToolbar = SecondaryToolbar;
 
 /***/ }),
-/* 35 */
+/* 36 */
 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
 
 
@@ -12743,7 +12939,7 @@ class PDFSinglePageViewer extends _base_viewer.BaseViewer {
 exports.PDFSinglePageViewer = PDFSinglePageViewer;
 
 /***/ }),
-/* 36 */
+/* 37 */
 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
 
 
@@ -13011,7 +13207,7 @@ class Toolbar {
 exports.Toolbar = Toolbar;
 
 /***/ }),
-/* 37 */
+/* 38 */
 /***/ ((__unused_webpack_module, exports) => {
 
 
@@ -13106,7 +13302,7 @@ class ViewHistory {
 exports.ViewHistory = ViewHistory;
 
 /***/ }),
-/* 38 */
+/* 39 */
 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
 
 
@@ -13116,13 +13312,13 @@ Object.defineProperty(exports, "__esModule", ({
 }));
 exports.FirefoxCom = exports.DownloadManager = void 0;
 
-__webpack_require__(39);
+__webpack_require__(40);
 
 var _app = __webpack_require__(3);
 
 var _pdfjsLib = __webpack_require__(5);
 
-var _preferences = __webpack_require__(40);
+var _preferences = __webpack_require__(41);
 
 var _ui_utils = __webpack_require__(4);
 
@@ -13530,7 +13726,7 @@ document.mozL10n.setExternalLocalizerServices({
 });
 
 /***/ }),
-/* 39 */
+/* 40 */
 /***/ (() => {
 
 
@@ -13652,7 +13848,7 @@ document.mozL10n.setExternalLocalizerServices({
 })(void 0);
 
 /***/ }),
-/* 40 */
+/* 41 */
 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
 
 
@@ -13785,7 +13981,7 @@ class BasePreferences {
 exports.BasePreferences = BasePreferences;
 
 /***/ }),
-/* 41 */
+/* 42 */
 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
 
 
@@ -13830,7 +14026,7 @@ function composePage(pdfDocument, pageNumber, size, printContainer, printResolut
           rotation: size.rotation
         }),
         intent: "print",
-        annotationStorage: pdfDocument.annotationStorage,
+        includeAnnotationStorage: true,
         optionalContentConfigPromise
       };
       currentRenderTask = thisRenderTask = pdfPage.render(renderContext);
@@ -13959,15 +14155,15 @@ var _app_options = __webpack_require__(1);
 
 var _app = __webpack_require__(3);
 
-const pdfjsVersion = '2.8.320';
-const pdfjsBuild = 'ca7f54682';
+const pdfjsVersion = '2.9.44';
+const pdfjsBuild = '6cf307000';
 window.PDFViewerApplication = _app.PDFViewerApplication;
 window.PDFViewerApplicationOptions = _app_options.AppOptions;
 ;
 {
-  __webpack_require__(38);
+  __webpack_require__(39);
 
-  __webpack_require__(41);
+  __webpack_require__(42);
 }
 ;
 ;
diff --git a/toolkit/components/pdfjs/moz.yaml b/toolkit/components/pdfjs/moz.yaml
index f8231ab0ba124..7131aebc0b866 100644
--- a/toolkit/components/pdfjs/moz.yaml
+++ b/toolkit/components/pdfjs/moz.yaml
@@ -20,7 +20,7 @@ origin:
 
   # Human-readable identifier for this version/release
   # Generally "version NNN", "tag SSS", "bookmark SSS"
-  release: version 2.8.320
+  release: version 2.9.44
 
   # The package's license, where possible using the mnemonic from
   # https://spdx.org/licenses/
-- 
GitLab