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",
|
"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",
|
||||||
|
@ -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: {
|
||||||
|
@ -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,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user