From 76f23ce3b5afa2e978c3d90306020d2405a7d27c Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 17 Apr 2025 13:57:30 +0200 Subject: [PATCH] Catch, and ignore, errors during `Page.prototype.getStructTree` This way any errors thrown during parsing of the page-structTree will not be forwarded to the viewer. --- src/core/document.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/core/document.js b/src/core/document.js index b1e1caaec..7324c9980 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -707,10 +707,18 @@ class Page { // Ensure that the structTree will contain the page's annotations. await this._parsedAnnotations; - const structTree = await this.pdfManager.ensure(this, "_parseStructTree", [ - structTreeRoot, - ]); - return this.pdfManager.ensure(structTree, "serializable"); + try { + const structTree = await this.pdfManager.ensure( + this, + "_parseStructTree", + [structTreeRoot] + ); + const data = await this.pdfManager.ensure(structTree, "serializable"); + return data; + } catch (ex) { + warn(`getStructTree: "${ex}".`); + return null; + } } /**