Merge pull request #13120 from Snuffleupagus/enablePrintAutoRotate-true

Rotate landscape pages, during printing, by default in the viewer (`enablePrintAutoRotate = true`)
This commit is contained in:
Tim van der Meij 2021-03-19 22:45:56 +01:00 committed by GitHub
commit 8a820ac151
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 18 deletions

View File

@ -173,7 +173,7 @@
"title": "Automatically rotate printed pages", "title": "Automatically rotate printed pages",
"description": "When enabled, landscape pages are rotated when printed.", "description": "When enabled, landscape pages are rotated when printed.",
"type": "boolean", "type": "boolean",
"default": false "default": true
}, },
"scrollModeOnLoad": { "scrollModeOnLoad": {
"title": "Scroll mode on load", "title": "Scroll mode on load",

View File

@ -62,7 +62,7 @@ const defaultOptions = {
}, },
enablePrintAutoRotate: { enablePrintAutoRotate: {
/** @type {boolean} */ /** @type {boolean} */
value: false, value: true,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE, kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
}, },
enableScripting: { enableScripting: {

View File

@ -1347,25 +1347,21 @@ class BaseViewer {
* @returns {Array} Array of objects with width/height/rotation fields. * @returns {Array} Array of objects with width/height/rotation fields.
*/ */
getPagesOverview() { getPagesOverview() {
const pagesOverview = this._pages.map(function (pageView) { return this._pages.map(pageView => {
const viewport = pageView.pdfPage.getViewport({ scale: 1 }); const viewport = pageView.pdfPage.getViewport({ scale: 1 });
return {
width: viewport.width, if (!this.enablePrintAutoRotate || isPortraitOrientation(viewport)) {
height: viewport.height, return {
rotation: viewport.rotation, width: viewport.width,
}; height: viewport.height,
}); rotation: viewport.rotation,
if (!this.enablePrintAutoRotate) { };
return pagesOverview;
}
return pagesOverview.map(function (size) {
if (isPortraitOrientation(size)) {
return size;
} }
// Landscape orientation.
return { return {
width: size.height, width: viewport.height,
height: size.width, height: viewport.width,
rotation: (size.rotation + 90) % 360, rotation: (viewport.rotation - 90) % 360,
}; };
}); });
} }