diff --git a/src/core/bounding_boxes.js b/src/core/bounding_boxes.js index 7e080b403092c..6a707b45bf659 100644 --- a/src/core/bounding_boxes.js +++ b/src/core/bounding_boxes.js @@ -15,6 +15,7 @@ class BoundingBoxesCalculator { this.boundingBoxes = {}; this.refBoundingBoxes = {}; this.ignoreCalculations = ignoreCalculations; + this.operandNameArray = []; this.operationArray = []; this.mcidArray = []; this.sameMcidDepth = 0; @@ -652,7 +653,8 @@ class BoundingBoxesCalculator { } break; case OPS.paintXObject: - const [type, bboxes] = args; + const [name, type, bboxes] = args; + this.operandNameArray[this.operationIndex] = name; if (type === "Image") { this.getImageBoundingBox(); this.saveGraphicsBoundingBox(); diff --git a/src/core/document.js b/src/core/document.js index 401606e0dcde5..3827df39c74f4 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -522,7 +522,8 @@ class Page { let MCIDBoundingBoxes, positionByOperationIndex, noMCIDBoundingBoxes, - refMCIDBoundingBoxes; + refMCIDBoundingBoxes, + operandNameByIndex; const pageListPromise = Promise.all([ contentStreamPromise, resourcesPromise, @@ -555,11 +556,13 @@ class Page { operationArray, boundingBoxesWithoutMCID, refBoundingBoxesByMCID, + operandNameArray, ]) { MCIDBoundingBoxes = boundingBoxesByMCID; positionByOperationIndex = operationArray; noMCIDBoundingBoxes = boundingBoxesWithoutMCID; refMCIDBoundingBoxes = refBoundingBoxesByMCID; + operandNameByIndex = operandNameArray; }); return opList; @@ -600,6 +603,7 @@ class Page { intent & RenderingIntentFlag.ANNOTATIONS_DISABLE ) { if (intent & RenderingIntentFlag.OPLIST) { + pageOpList.addOp(OPS.operandName, operandNameByIndex); pageOpList.addOp(OPS.annotBBoxesAndOpPos, []); pageOpList.addOp(OPS.operationPosition, positionByOperationIndex); pageOpList.addOp(OPS.boundingBoxes, [ @@ -668,6 +672,7 @@ class Page { ); } if (intent & RenderingIntentFlag.OPLIST) { + pageOpList.addOp(OPS.operandName, operandNameByIndex); pageOpList.addOp( OPS.annotBBoxesAndOpPos, annotationsBBoxesAndOperationPosition diff --git a/src/core/evaluator.js b/src/core/evaluator.js index c321b2217e4dc..6c84c3baee115 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -1814,6 +1814,7 @@ class PartialEvaluator { const localImage = localImageCache.getByName(name); if (localImage) { boundingBoxCalculator.parseOperator(OPS.paintXObject, [ + name, "Image", ]); addCachedImageOps(operatorList, localImage); @@ -1837,6 +1838,7 @@ class PartialEvaluator { if (cachedImage) { boundingBoxCalculator.parseOperator(OPS.paintXObject, [ + name, "Image", ]); addCachedImageOps(operatorList, cachedImage); @@ -1879,6 +1881,7 @@ class PartialEvaluator { boundingBoxesByMCID ); boundingBoxCalculator.parseOperator(OPS.paintXObject, [ + name, type.name, boundingBoxesWithoutMCID, ]); @@ -1889,6 +1892,7 @@ class PartialEvaluator { return; } else if (type.name === "Image") { boundingBoxCalculator.parseOperator(OPS.paintXObject, [ + name, type.name, ]); self @@ -2439,6 +2443,7 @@ class PartialEvaluator { boundingBoxCalculator.operationArray, boundingBoxCalculator.getNoMCIDBoundingBoxes(), boundingBoxCalculator.refBoundingBoxes, + boundingBoxCalculator.operandNameArray, ]); }).catch(reason => { if (reason instanceof AbortException) { diff --git a/src/shared/util.js b/src/shared/util.js index 0261e0d62fde2..4a6e96125c146 100644 --- a/src/shared/util.js +++ b/src/shared/util.js @@ -343,6 +343,7 @@ const OPS = { boundingBoxes: 100, operationPosition: 101, annotBBoxesAndOpPos: 102, + operandName: 103, }; // In order to have a switch statement that is fast (i.e. which use a jump