1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

Add an OutputScale static method to get the devicePixelRatio

Currently we lookup the `devicePixelRatio`, with fallback handling, in a number of spots in the code-base.
Rather than duplicating code we can instead add a new static method in the `OutputScale` class, since that one is now exposed in the API.
This commit is contained in:
Jonas Jenwald 2025-03-12 14:03:51 +01:00
parent e4795f639c
commit 319d239f41
7 changed files with 25 additions and 17 deletions

View file

@ -20,6 +20,7 @@ const {
DrawLayer,
getDocument,
GlobalWorkerOptions,
OutputScale,
PixelsPerInch,
shadow,
TextLayer,
@ -876,7 +877,7 @@ class Driver {
page => {
// Default to creating the test images at the devices pixel ratio,
// unless the test explicitly specifies an output scale.
const outputScale = task.outputScale || window.devicePixelRatio;
const outputScale = task.outputScale || OutputScale.pixelRatio;
let viewport = page.getViewport({
scale: PixelsPerInch.PDF_TO_CSS_UNITS,
});