1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Re-factor the CSS_PIXELS_PER_INCH/PDF_PIXELS_PER_INCH exports (PR 13991 follow-up)

For improved maintainability, since these constants are being exposed in the official API, this patch moves them into an Object instead.
This commit is contained in:
Jonas Jenwald 2021-09-11 11:11:32 +02:00
parent bd51bbfd16
commit 0e54f568fb
7 changed files with 18 additions and 20 deletions

View file

@ -15,7 +15,7 @@
import {
AnnotationMode,
PDF_PIXELS_PER_INCH,
PixelsPerInch,
RenderingCancelledException,
shadow,
} from "pdfjs-lib";
@ -34,7 +34,7 @@ function composePage(
const canvas = document.createElement("canvas");
// The size of the canvas in pixels for printing.
const PRINT_UNITS = printResolution / PDF_PIXELS_PER_INCH;
const PRINT_UNITS = printResolution / PixelsPerInch.PDF;
canvas.width = Math.floor(size.width * PRINT_UNITS);
canvas.height = Math.floor(size.height * PRINT_UNITS);

View file

@ -13,7 +13,7 @@
* limitations under the License.
*/
import { AnnotationMode, PDF_PIXELS_PER_INCH } from "pdfjs-lib";
import { AnnotationMode, PixelsPerInch } from "pdfjs-lib";
import { PDFPrintServiceFactory, PDFViewerApplication } from "./app.js";
import { compatibilityParams } from "./app_options.js";
import { getXfaHtmlForPrinting } from "./print_utils.js";
@ -34,7 +34,7 @@ function renderPage(
const scratchCanvas = activeService.scratchCanvas;
// The size of the canvas in pixels for printing.
const PRINT_UNITS = printResolution / PDF_PIXELS_PER_INCH;
const PRINT_UNITS = printResolution / PixelsPerInch.PDF;
scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);

View file

@ -13,9 +13,9 @@
* limitations under the License.
*/
import { CSS_PIXELS_PER_INCH, PDF_PIXELS_PER_INCH } from "pdfjs-lib";
import { PixelsPerInch } from "pdfjs-lib";
const CSS_UNITS = CSS_PIXELS_PER_INCH / PDF_PIXELS_PER_INCH;
const CSS_UNITS = PixelsPerInch.CSS / PixelsPerInch.PDF;
const DEFAULT_SCALE_VALUE = "auto";
const DEFAULT_SCALE = 1.0;
const MIN_SCALE = 0.1;