make print resolution configurable via AppOptions

This commit is contained in:
Stefan Klein 2019-05-24 11:49:41 +02:00
parent 1421b2f205
commit b85209f1fd
2 changed files with 7 additions and 1 deletions

View File

@ -233,6 +233,11 @@ if (typeof PDFJSDev === 'undefined' ||
value: (typeof navigator !== 'undefined' ? navigator.language : 'en-US'), value: (typeof navigator !== 'undefined' ? navigator.language : 'en-US'),
kind: OptionKind.VIEWER, kind: OptionKind.VIEWER,
}; };
defaultOptions.printResolution = {
/** @type {number} */
value: 150,
kind: OptionKind.VIEWER,
};
} }
const userOptions = Object.create(null); const userOptions = Object.create(null);

View File

@ -15,6 +15,7 @@
import { CSS_UNITS, NullL10n } from './ui_utils'; import { CSS_UNITS, NullL10n } from './ui_utils';
import { PDFPrintServiceFactory, PDFViewerApplication } from './app'; import { PDFPrintServiceFactory, PDFViewerApplication } from './app';
import { AppOptions } from './app_options';
import { URL } from 'pdfjs-lib'; import { URL } from 'pdfjs-lib';
let activeService = null; let activeService = null;
@ -26,7 +27,7 @@ function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
let scratchCanvas = activeService.scratchCanvas; let scratchCanvas = activeService.scratchCanvas;
// The size of the canvas in pixels for printing. // 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; const PRINT_UNITS = PRINT_RESOLUTION / 72.0;
scratchCanvas.width = Math.floor(size.width * PRINT_UNITS); scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
scratchCanvas.height = Math.floor(size.height * PRINT_UNITS); scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);