1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

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
This commit is contained in:
Jonas Jenwald 2025-03-06 22:49:58 +01:00
parent af89e77124
commit eef15a30cd

View file

@ -215,9 +215,21 @@ class PDFThumbnailView {
willReadFrequently: !enableHWA,
});
const outputScale = new OutputScale();
const width = upscaleFactor * this.canvasWidth,
height = upscaleFactor * this.canvasHeight;
canvas.width = (upscaleFactor * this.canvasWidth * outputScale.sx) | 0;
canvas.height = (upscaleFactor * this.canvasHeight * outputScale.sy) | 0;
if (this.maxCanvasDim !== -1) {
const maxScale = Math.min(
this.maxCanvasDim / width,
this.maxCanvasDim / height
);
if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
outputScale.sx = maxScale;
outputScale.sy = maxScale;
}
}
canvas.width = (width * outputScale.sx) | 0;
canvas.height = (height * outputScale.sy) | 0;
const transform = outputScale.scaled
? [outputScale.sx, 0, 0, outputScale.sy, 0, 0]