From 9103b5bcb89a117dfa9cc14c25ab5542bad0a918 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Fri, 13 Feb 2026 15:28:15 +0300 Subject: [PATCH] The error artifacts is not highlighted --- src/core/bounding_boxes.js | 16 +++++++++++++++- src/core/evaluator.js | 6 +++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/core/bounding_boxes.js b/src/core/bounding_boxes.js index e43390008f9a9..aecbaf43de793 100644 --- a/src/core/bounding_boxes.js +++ b/src/core/bounding_boxes.js @@ -507,6 +507,8 @@ class BoundingBoxesCalculator { state.y = Math.min(y0, y1, y2, y3); state.w = Math.max(x0, x1, x2, x3) - state.x; state.h = Math.max(y0, y1, y2, y3) - state.y; + + this.operationArray[this.operationIndex] = [[state.x, state.y, state.w, state.h]]; } parseOperator(fn, args) { @@ -712,9 +714,21 @@ class BoundingBoxesCalculator { } break; case OPS.paintXObject: - if (args[0] === "Image") { + const [type, bboxes] = args; + if (type === "Image") { this.getImageBoundingBox(); this.saveGraphicsBoundingBox(); + } else if (type === "Form" && typeof bboxes === "object") { + const opArr = Object.values(bboxes).map((b) => { + let { contentItems, contentItem } = b; + while (contentItems?.length) { + [{ contentItems, contentItem }] = contentItems; + } + if (contentItem?.x == null) return []; + const { x, y, w, h } = contentItem; + return [x, y, w, h]; + }); + this.operationArray[this.operationIndex] = opArr; } break; case OPS.showText: diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 83f8ff275d46b..c321b2217e4dc 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -1873,11 +1873,15 @@ class PartialEvaluator { boundingBoxCalculator.textState, boundingBoxCalculator.graphicsState ) - .then(function ([boundingBoxesByMCID]) { + .then(function ([boundingBoxesByMCID, _, boundingBoxesWithoutMCID]) { boundingBoxCalculator.addRefBoundingBoxes( xobj.dict.objId, boundingBoxesByMCID ); + boundingBoxCalculator.parseOperator(OPS.paintXObject, [ + type.name, + boundingBoxesWithoutMCID, + ]); stateManager.restore(); boundingBoxCalculator.restoreState(); resolveXObject();