In the struct tree a kid can be a reference to an MCID entry (issue #19694)
This commit is contained in:
parent
a8c77633a1
commit
dee80cb082
@ -565,7 +565,10 @@ class StructElementNode {
|
|||||||
const kids = this.dict.get("K");
|
const kids = this.dict.get("K");
|
||||||
if (Array.isArray(kids)) {
|
if (Array.isArray(kids)) {
|
||||||
for (const kid of kids) {
|
for (const kid of kids) {
|
||||||
const element = this.parseKid(pageObjId, kid);
|
const element = this.parseKid(
|
||||||
|
pageObjId,
|
||||||
|
this.dict.xref.fetchIfRef(kid)
|
||||||
|
);
|
||||||
if (element) {
|
if (element) {
|
||||||
this.kids.push(element);
|
this.kids.push(element);
|
||||||
}
|
}
|
||||||
@ -592,33 +595,26 @@ class StructElementNode {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the dictionary for the kid.
|
if (!(kid instanceof Dict)) {
|
||||||
let kidDict = null;
|
|
||||||
if (kid instanceof Ref) {
|
|
||||||
kidDict = this.dict.xref.fetch(kid);
|
|
||||||
} else if (kid instanceof Dict) {
|
|
||||||
kidDict = kid;
|
|
||||||
}
|
|
||||||
if (!kidDict) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const pageRef = kidDict.getRaw("Pg");
|
|
||||||
|
const pageRef = kid.getRaw("Pg");
|
||||||
if (pageRef instanceof Ref) {
|
if (pageRef instanceof Ref) {
|
||||||
pageObjId = pageRef.toString();
|
pageObjId = pageRef.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
const type =
|
const type = kid.get("Type") instanceof Name ? kid.get("Type").name : null;
|
||||||
kidDict.get("Type") instanceof Name ? kidDict.get("Type").name : null;
|
|
||||||
if (type === "MCR") {
|
if (type === "MCR") {
|
||||||
if (this.tree.pageDict.objId !== pageObjId) {
|
if (this.tree.pageDict.objId !== pageObjId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const kidRef = kidDict.getRaw("Stm");
|
const kidRef = kid.getRaw("Stm");
|
||||||
return new StructElement({
|
return new StructElement({
|
||||||
type: StructElementType.STREAM_CONTENT,
|
type: StructElementType.STREAM_CONTENT,
|
||||||
refObjId: kidRef instanceof Ref ? kidRef.toString() : null,
|
refObjId: kidRef instanceof Ref ? kidRef.toString() : null,
|
||||||
pageObjId,
|
pageObjId,
|
||||||
mcid: kidDict.get("MCID"),
|
mcid: kid.get("MCID"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -626,7 +622,7 @@ class StructElementNode {
|
|||||||
if (this.tree.pageDict.objId !== pageObjId) {
|
if (this.tree.pageDict.objId !== pageObjId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const kidRef = kidDict.getRaw("Obj");
|
const kidRef = kid.getRaw("Obj");
|
||||||
return new StructElement({
|
return new StructElement({
|
||||||
type: StructElementType.OBJECT,
|
type: StructElementType.OBJECT,
|
||||||
refObjId: kidRef instanceof Ref ? kidRef.toString() : null,
|
refObjId: kidRef instanceof Ref ? kidRef.toString() : null,
|
||||||
@ -636,7 +632,7 @@ class StructElementNode {
|
|||||||
|
|
||||||
return new StructElement({
|
return new StructElement({
|
||||||
type: StructElementType.ELEMENT,
|
type: StructElementType.ELEMENT,
|
||||||
dict: kidDict,
|
dict: kid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user