Skip to content

Commit 1bc98df

Browse files
authoredMar 10, 2025··
Merge pull request #19621 from Snuffleupagus/bug-1943094-thumbs
Limit the maximum thumbnail canvas width/height, similar to pages (PR 19604 follow-up)
2 parents 81baa16 + eef15a3 commit 1bc98df

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed
 

‎web/pdf_thumbnail_view.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,21 @@ class PDFThumbnailView {
215215
willReadFrequently: !enableHWA,
216216
});
217217
const outputScale = new OutputScale();
218+
const width = upscaleFactor * this.canvasWidth,
219+
height = upscaleFactor * this.canvasHeight;
218220

219-
canvas.width = (upscaleFactor * this.canvasWidth * outputScale.sx) | 0;
220-
canvas.height = (upscaleFactor * this.canvasHeight * outputScale.sy) | 0;
221+
if (this.maxCanvasDim !== -1) {
222+
const maxScale = Math.min(
223+
this.maxCanvasDim / width,
224+
this.maxCanvasDim / height
225+
);
226+
if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
227+
outputScale.sx = maxScale;
228+
outputScale.sy = maxScale;
229+
}
230+
}
231+
canvas.width = (width * outputScale.sx) | 0;
232+
canvas.height = (height * outputScale.sy) | 0;
221233

222234
const transform = outputScale.scaled
223235
? [outputScale.sx, 0, 0, outputScale.sy, 0, 0]

0 commit comments

Comments
 (0)
Please sign in to comment.