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:
parent
af89e77124
commit
eef15a30cd
1 changed files with 14 additions and 2 deletions
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue