diff --git a/src/core/document.js b/src/core/document.js index 27cbede28..072ae3770 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -454,7 +454,13 @@ class Page { const structTreeRoot = await this.pdfManager.ensureCatalog( "structTreeRoot" ); - return this.pdfManager.ensure(this, "_parseStructTree", [structTreeRoot]); + if (!structTreeRoot) { + return null; + } + const structTree = await this.pdfManager.ensure(this, "_parseStructTree", [ + structTreeRoot, + ]); + return structTree.serializable; } /** diff --git a/src/core/struct_tree.js b/src/core/struct_tree.js index a07d99b96..41587d45c 100644 --- a/src/core/struct_tree.js +++ b/src/core/struct_tree.js @@ -328,10 +328,6 @@ class StructTreePage { } nodeToSerializable(child, root); } - - if (root.children.length === 0) { - return null; - } return root; } } diff --git a/src/core/worker.js b/src/core/worker.js index 2011deb4c..76f47a250 100644 --- a/src/core/worker.js +++ b/src/core/worker.js @@ -487,7 +487,7 @@ class WorkerMessageHandler { handler.on("GetPageJSActions", function ({ pageIndex }) { return pdfManager.getPage(pageIndex).then(function (page) { - return page.jsActions; + return pdfManager.ensure(page, "jsActions"); }); }); @@ -497,10 +497,6 @@ class WorkerMessageHandler { }); }); - handler.on("GetIsPureXfa", function wphSetupGetIsPureXfa(data) { - return pdfManager.ensureDoc("isPureXfa"); - }); - handler.on("GetOutline", function wphSetupGetOutline(data) { return pdfManager.ensureCatalog("documentOutline"); }); @@ -747,15 +743,9 @@ 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; - }); + return pdfManager.getPage(data.pageIndex).then(function (page) { + return pdfManager.ensure(page, "getStructTree"); + }); }); handler.on("FontFallback", function (data) {