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.
This commit is contained in:
Jonas Jenwald 2021-04-20 19:51:01 +02:00
parent fd82adccfa
commit 8f6543c218

View File

@ -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]);