Skip to content

Commit

Permalink
Remove mcid overriding
Browse files Browse the repository at this point in the history
  • Loading branch information
GribovskyPavel committed Feb 19, 2024
1 parent 842ea70 commit 0cffb5d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/core/bounding_boxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ var BoundingBoxesCalculator = (function PartialEvaluatorClosure() {
this.boundingBoxes = {};
this.ignoreCalculations = ignoreCalculations;
this.operationArray = [];
this.mcidArray = [];
this.sameMcidDepth = 0;
this.operationIndex = -1;
}

Expand Down Expand Up @@ -410,6 +412,22 @@ var BoundingBoxesCalculator = (function PartialEvaluatorClosure() {
this.boundingBoxesStack.inc();
}

// Prevent parsing of Marked content with same MCIDs
if (fn === OPS.beginMarkedContentProps && isDict(args[1]) && args[1].has('MCID')) {
const mcid = args[1].get('MCID');
if (this.mcidArray.includes(mcid)) {
this.sameMcidDepth++;
return;
} else {
this.mcidArray.push(mcid);
}
}

if (fn === OPS.endMarkedContent && this.sameMcidDepth !== 0) {
this.sameMcidDepth--;
return;
}

switch (fn | 0) {
case OPS.restore:
this.graphicsStateManager.restore();
Expand Down
2 changes: 2 additions & 0 deletions src/core/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,7 @@ class ExtendedCatalog extends Catalog {
name: name ? stringToUTF8String(name) : null,
roleName: roleName ? stringToUTF8String(roleName) : null,
children: this.getTreeElement(el.get('K'), page, el.getRaw('K')),
pageIndex: page,
ref: ref
};
}
Expand Down Expand Up @@ -1695,6 +1696,7 @@ class ExtendedCatalog extends Catalog {
name: name ? stringToUTF8String(name) : null,
roleName: roleName ? stringToUTF8String(roleName) : null,
children: [],
pageIndex: page,
ref: ref
};
}
Expand Down

0 comments on commit 0cffb5d

Please sign in to comment.