mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-05 22:07:22 +02:00
Merge pull request #19824 from Snuffleupagus/getStructTree-catch-errors
Improve error handling when parsing page-structTrees
This commit is contained in:
commit
f1e20cd668
@ -707,10 +707,18 @@ class Page {
|
|||||||
// Ensure that the structTree will contain the page's annotations.
|
// Ensure that the structTree will contain the page's annotations.
|
||||||
await this._parsedAnnotations;
|
await this._parsedAnnotations;
|
||||||
|
|
||||||
const structTree = await this.pdfManager.ensure(this, "_parseStructTree", [
|
try {
|
||||||
structTreeRoot,
|
const structTree = await this.pdfManager.ensure(
|
||||||
]);
|
this,
|
||||||
return this.pdfManager.ensure(structTree, "serializable");
|
"_parseStructTree",
|
||||||
|
[structTreeRoot]
|
||||||
|
);
|
||||||
|
const data = await this.pdfManager.ensure(structTree, "serializable");
|
||||||
|
return data;
|
||||||
|
} catch (ex) {
|
||||||
|
warn(`getStructTree: "${ex}".`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -757,7 +757,10 @@ class StructTreePage {
|
|||||||
|
|
||||||
const parent = dict.get("P");
|
const parent = dict.get("P");
|
||||||
|
|
||||||
if (!parent || isName(parent.get("Type"), "StructTreeRoot")) {
|
if (
|
||||||
|
!(parent instanceof Dict) ||
|
||||||
|
isName(parent.get("Type"), "StructTreeRoot")
|
||||||
|
) {
|
||||||
if (!this.addTopLevelNode(dict, element)) {
|
if (!this.addTopLevelNode(dict, element)) {
|
||||||
map.delete(dict);
|
map.delete(dict);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user