From b85209f1fd4047607467dcc52373b7c368c11c35 Mon Sep 17 00:00:00 2001 From: Stefan Klein Date: Fri, 24 May 2019 11:49:41 +0200 Subject: [PATCH] make print resolution configurable via AppOptions --- web/app_options.js | 5 +++++ web/pdf_print_service.js | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/web/app_options.js b/web/app_options.js index ea9878314..73c86c765 100644 --- a/web/app_options.js +++ b/web/app_options.js @@ -233,6 +233,11 @@ if (typeof PDFJSDev === 'undefined' || value: (typeof navigator !== 'undefined' ? navigator.language : 'en-US'), kind: OptionKind.VIEWER, }; + defaultOptions.printResolution = { + /** @type {number} */ + value: 150, + kind: OptionKind.VIEWER, + }; } const userOptions = Object.create(null); diff --git a/web/pdf_print_service.js b/web/pdf_print_service.js index 12075921a..b8de6e274 100644 --- a/web/pdf_print_service.js +++ b/web/pdf_print_service.js @@ -15,6 +15,7 @@ import { CSS_UNITS, NullL10n } from './ui_utils'; import { PDFPrintServiceFactory, PDFViewerApplication } from './app'; +import { AppOptions } from './app_options'; import { URL } from 'pdfjs-lib'; let activeService = null; @@ -26,7 +27,7 @@ function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) { let scratchCanvas = activeService.scratchCanvas; // The size of the canvas in pixels for printing. - const PRINT_RESOLUTION = 150; + const PRINT_RESOLUTION = AppOptions.get('printResolution') || 150; const PRINT_UNITS = PRINT_RESOLUTION / 72.0; scratchCanvas.width = Math.floor(size.width * PRINT_UNITS); scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);