From 8f6543c218efd11677702ff978eda8a041201fd0 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 20 Apr 2021 19:51:01 +0200 Subject: [PATCH] Ensure that the /Properties, used with optional content, is actually loaded *before* parsing the operatorList/textContent (PR 12095 follow-up) By not waiting for the /Properties to load, before parsing of the operatorList/textContent starts, there's a very real risk that a `MissingDataException` will be thrown when trying to access the data in the `PartialEvaluator.parseMarkedContentProps` method. If this ever happens it will thus lead to incomplete and/or outright broken rendering, and with e.g. `disableAutoFetch=true` set the likelihood of this occuring would increase quite a bit. *Please note:* While I've not yet seen this error in an actual PDF document, it can happen during loading if you're unlucky enough with e.g. the structure of the PDF document and/or the download speed offered by the server. --- src/core/document.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/document.js b/src/core/document.js index 606742842..0682d7813 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -318,12 +318,13 @@ class Page { "getContentStream" ); const resourcesPromise = this.loadResources([ - "ExtGState", "ColorSpace", + "ExtGState", + "Font", "Pattern", + "Properties", "Shading", "XObject", - "Font", ]); const partialEvaluator = new PartialEvaluator({ @@ -425,8 +426,9 @@ class Page { ); const resourcesPromise = this.loadResources([ "ExtGState", - "XObject", "Font", + "Properties", + "XObject", ]); const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);