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",
"description": "When enabled, landscape pages are rotated when printed.",
"type": "boolean",
"default": false
"default": true
},
"scrollModeOnLoad": {
"title": "Scroll mode on load",

View File

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

View File

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