Merge pull request #18218 from nicolo-ribaudo/test-maxCanvasPixels

Respect `maxCanvasPixels` when computing canvas dimensions
This commit is contained in:
Tim van der Meij 2024-06-19 16:47:09 +02:00 committed by GitHub
commit 3e1d779859
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 187 additions and 62 deletions

View file

@ -34,9 +34,9 @@ import {
import {
approximateFraction,
DEFAULT_SCALE,
floorToDivide,
OutputScale,
RenderingStates,
roundToDivide,
TextLayerMode,
} from "./ui_utils.js";
import { AnnotationEditorLayerBuilder } from "./annotation_editor_layer_builder.js";
@ -1016,11 +1016,11 @@ class PDFPageView {
const sfx = approximateFraction(outputScale.sx);
const sfy = approximateFraction(outputScale.sy);
canvas.width = roundToDivide(width * outputScale.sx, sfx[0]);
canvas.height = roundToDivide(height * outputScale.sy, sfy[0]);
canvas.width = floorToDivide(width * outputScale.sx, sfx[0]);
canvas.height = floorToDivide(height * outputScale.sy, sfy[0]);
const { style } = canvas;
style.width = roundToDivide(width, sfx[1]) + "px";
style.height = roundToDivide(height, sfy[1]) + "px";
style.width = floorToDivide(width, sfx[1]) + "px";
style.height = floorToDivide(height, sfy[1]) + "px";
// Add the viewport so it's known what it was originally drawn with.
this.#viewportMap.set(canvas, viewport);