Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/core/struct_tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class StructTreeRoot {
this.roleMap = new Map();
this.structParentIds = null;
this.kidRefToPosition = undefined;
this.parentTree = null;
}

getKidPosition(kidRef) {
Expand Down Expand Up @@ -70,6 +71,11 @@ class StructTreeRoot {

init() {
this.readRoleMap();
const parentTree = this.dict.get("ParentTree");
if (!parentTree) {
return;
}
this.parentTree = new NumberTree(parentTree, this.xref);
}

#addIdToPage(pageRef, id, type) {
Expand Down Expand Up @@ -771,7 +777,7 @@ class StructTreePage {
return;
}

const parentTree = this.rootDict.get("ParentTree");
const { parentTree } = this.root;
if (!parentTree) {
return;
}
Expand All @@ -782,10 +788,9 @@ class StructTreePage {
}

const map = new Map();
const numberTree = new NumberTree(parentTree, this.xref);

if (Number.isInteger(id)) {
const parentArray = numberTree.get(id);
const parentArray = parentTree.get(id);
if (Array.isArray(parentArray)) {
for (const ref of parentArray) {
if (ref instanceof Ref) {
Expand All @@ -799,7 +804,7 @@ class StructTreePage {
return;
}
for (const [elemId, type] of ids) {
const obj = numberTree.get(elemId);
const obj = parentTree.get(elemId);
if (obj) {
const elem = this.addNode(this.xref.fetchIfRef(obj), map);
if (
Expand Down