mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
Respect maxCanvasPixels
when computing canvas dimensions
Ensure that we never round the canvas dimensions above `maxCanvasPixels` by rounding them to the preceeding multiple of the display ratio rather than the succeeding one.
This commit is contained in:
parent
12692d2e39
commit
de23bb9b82
3 changed files with 20 additions and 15 deletions
|
@ -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";
|
||||
|
@ -1025,11 +1025,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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue