mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-22 16:05:56 +02:00
parent
918a319de6
commit
5992d0f097
@ -483,6 +483,10 @@ class PartialEvaluator {
|
|||||||
const { dict } = xobj;
|
const { dict } = xobj;
|
||||||
const matrix = lookupMatrix(dict.getArray("Matrix"), null);
|
const matrix = lookupMatrix(dict.getArray("Matrix"), null);
|
||||||
const bbox = lookupNormalRect(dict.getArray("BBox"), null);
|
const bbox = lookupNormalRect(dict.getArray("BBox"), null);
|
||||||
|
let f32bbox = bbox && new Float32Array(bbox);
|
||||||
|
if (f32bbox?.some(x => !isFinite(x))) {
|
||||||
|
f32bbox = null;
|
||||||
|
}
|
||||||
|
|
||||||
let optionalContent, groupOptions;
|
let optionalContent, groupOptions;
|
||||||
if (dict.has("OC")) {
|
if (dict.has("OC")) {
|
||||||
@ -498,7 +502,7 @@ class PartialEvaluator {
|
|||||||
if (group) {
|
if (group) {
|
||||||
groupOptions = {
|
groupOptions = {
|
||||||
matrix,
|
matrix,
|
||||||
bbox,
|
bbox: f32bbox,
|
||||||
smask,
|
smask,
|
||||||
isolated: false,
|
isolated: false,
|
||||||
knockout: false,
|
knockout: false,
|
||||||
@ -532,8 +536,7 @@ class PartialEvaluator {
|
|||||||
// bounding box and translated to the correct position so we don't need to
|
// bounding box and translated to the correct position so we don't need to
|
||||||
// apply the bounding box to it.
|
// apply the bounding box to it.
|
||||||
const f32matrix = matrix && new Float32Array(matrix);
|
const f32matrix = matrix && new Float32Array(matrix);
|
||||||
const f32bbox = (!group && bbox && new Float32Array(bbox)) || null;
|
const args = [f32matrix, (!group && f32bbox) || null];
|
||||||
const args = [f32matrix, f32bbox];
|
|
||||||
operatorList.addOp(OPS.paintFormXObjectBegin, args);
|
operatorList.addOp(OPS.paintFormXObjectBegin, args);
|
||||||
|
|
||||||
const localResources = dict.get("Resources");
|
const localResources = dict.get("Resources");
|
||||||
|
|||||||
@ -2576,18 +2576,6 @@ class CanvasGraphics {
|
|||||||
if (group.matrix) {
|
if (group.matrix) {
|
||||||
currentCtx.transform(...group.matrix);
|
currentCtx.transform(...group.matrix);
|
||||||
}
|
}
|
||||||
if (!group.bbox) {
|
|
||||||
throw new Error("Bounding box is required.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Based on the current transform figure out how big the bounding box
|
|
||||||
// will actually be.
|
|
||||||
let bounds = MIN_MAX_INIT.slice();
|
|
||||||
Util.axialAlignedBoundingBox(
|
|
||||||
group.bbox,
|
|
||||||
getCurrentTransform(currentCtx),
|
|
||||||
bounds
|
|
||||||
);
|
|
||||||
|
|
||||||
// Clip the bounding box to the current canvas.
|
// Clip the bounding box to the current canvas.
|
||||||
const canvasBounds = [
|
const canvasBounds = [
|
||||||
@ -2596,7 +2584,23 @@ class CanvasGraphics {
|
|||||||
currentCtx.canvas.width,
|
currentCtx.canvas.width,
|
||||||
currentCtx.canvas.height,
|
currentCtx.canvas.height,
|
||||||
];
|
];
|
||||||
bounds = Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
|
|
||||||
|
let bounds;
|
||||||
|
if (group.bbox) {
|
||||||
|
bounds = MIN_MAX_INIT.slice();
|
||||||
|
Util.axialAlignedBoundingBox(
|
||||||
|
group.bbox,
|
||||||
|
getCurrentTransform(currentCtx),
|
||||||
|
bounds
|
||||||
|
);
|
||||||
|
|
||||||
|
bounds = Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
|
||||||
|
} else {
|
||||||
|
bounds = canvasBounds;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Based on the current transform figure out how big the bounding box
|
||||||
|
// will actually be.
|
||||||
// Use ceil in case we're between sizes so we don't create canvas that is
|
// Use ceil in case we're between sizes so we don't create canvas that is
|
||||||
// too small and make the canvas at least 1x1 pixels.
|
// too small and make the canvas at least 1x1 pixels.
|
||||||
const offsetX = Math.floor(bounds[0]);
|
const offsetX = Math.floor(bounds[0]);
|
||||||
@ -2624,15 +2628,17 @@ class CanvasGraphics {
|
|||||||
groupCtx.transform(...currentTransform);
|
groupCtx.transform(...currentTransform);
|
||||||
|
|
||||||
// Apply the bbox to the group context.
|
// Apply the bbox to the group context.
|
||||||
let clip = new Path2D();
|
if (group.bbox) {
|
||||||
const [x0, y0, x1, y1] = group.bbox;
|
let clip = new Path2D();
|
||||||
clip.rect(x0, y0, x1 - x0, y1 - y0);
|
const [x0, y0, x1, y1] = group.bbox;
|
||||||
if (group.matrix) {
|
clip.rect(x0, y0, x1 - x0, y1 - y0);
|
||||||
const path = new Path2D();
|
if (group.matrix) {
|
||||||
path.addPath(clip, new DOMMatrix(group.matrix));
|
const path = new Path2D();
|
||||||
clip = path;
|
path.addPath(clip, new DOMMatrix(group.matrix));
|
||||||
|
clip = path;
|
||||||
|
}
|
||||||
|
groupCtx.clip(clip);
|
||||||
}
|
}
|
||||||
groupCtx.clip(clip);
|
|
||||||
|
|
||||||
if (group.smask) {
|
if (group.smask) {
|
||||||
// Saving state and cached mask to be used in setGState.
|
// Saving state and cached mask to be used in setGState.
|
||||||
|
|||||||
1
test/pdfs/issue20872.pdf.link
Normal file
1
test/pdfs/issue20872.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://github.com/user-attachments/files/26001581/issue20872.pdf
|
||||||
@ -14012,5 +14012,13 @@
|
|||||||
"md5": "321f0901af604a6052baa7b2855a7e3e",
|
"md5": "321f0901af604a6052baa7b2855a7e3e",
|
||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"type": "text"
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "issue20872",
|
||||||
|
"file": "pdfs/issue20872.pdf",
|
||||||
|
"md5": "2394eea595990d0148b209fe49f035e5",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": true,
|
||||||
|
"type": "eq"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user