Skip to content

Commit eef15a3

Browse files
committed
Limit the maximum thumbnail canvas width/height, similar to pages (PR 19604 follow-up)
The changes in PR 19604 weren't enough for thumbnail canvases in some cases, see e.g. https://web.archive.org/web/20231204152348if_/https://user.informatik.uni-bremen.de/cabo/rfc9000.pdf#pagemode=thumbs
1 parent af89e77 commit eef15a3

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)