mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +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
2 changed files with 16 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -757,7 +757,10 @@ class StructTreePage {
|
|||
|
||||
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)) {
|
||||
map.delete(dict);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue