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:
commit
8a820ac151
@ -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",
|
||||
|
@ -62,7 +62,7 @@ const defaultOptions = {
|
||||
},
|
||||
enablePrintAutoRotate: {
|
||||
/** @type {boolean} */
|
||||
value: false,
|
||||
value: true,
|
||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||
},
|
||||
enableScripting: {
|
||||
|
@ -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,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user