Merge pull request #16241 from fchasen/bug_1820651

[Firefox] Add CSS at-page size when printing from FirefoxPrintService (bug 1820651)
This commit is contained in:
Jonas Jenwald 2023-04-05 21:03:46 +02:00 committed by GitHub
commit 65c4a4b3fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 12 deletions

View file

@ -1666,21 +1666,27 @@ class PDFViewer {
* @returns {Array} Array of objects with width/height/rotation fields.
*/
getPagesOverview() {
let initialOrientation;
return this._pages.map(pageView => {
const viewport = pageView.pdfPage.getViewport({ scale: 1 });
if (!this.enablePrintAutoRotate || isPortraitOrientation(viewport)) {
const orientation = isPortraitOrientation(viewport);
if (initialOrientation === undefined) {
initialOrientation = orientation;
} else if (
this.enablePrintAutoRotate &&
orientation !== initialOrientation
) {
// Rotate to fit the initial orientation.
return {
width: viewport.width,
height: viewport.height,
rotation: viewport.rotation,
width: viewport.height,
height: viewport.width,
rotation: (viewport.rotation - 90) % 360,
};
}
// Landscape orientation.
return {
width: viewport.height,
height: viewport.width,
rotation: (viewport.rotation - 90) % 360,
width: viewport.width,
height: viewport.height,
rotation: viewport.rotation,
};
});
}