mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
[api-minor] Change the getViewport
method, on PDFPageProxy
, to take a parameter object rather than a bunch of (randomly) ordered parameters
If, as PR 10368 suggests, more parameters should be added to `getViewport` I think that it would be a mistake to not change the signature *first* to avoid needlessly unwieldy call-sites. To not break any existing code and third-party use-cases, this is obviously implemented with a deprecation warning *and* with a working fallback[1] for the old method signature. --- [1] This is limited to `GENERIC` builds, which should be sufficient.
This commit is contained in:
parent
ba2edeae18
commit
f0719ed565
19 changed files with 54 additions and 38 deletions
|
@ -419,7 +419,7 @@ class BaseViewer {
|
|||
// viewport for all pages
|
||||
firstPagePromise.then((pdfPage) => {
|
||||
let scale = this.currentScale;
|
||||
let viewport = pdfPage.getViewport(scale * CSS_UNITS);
|
||||
let viewport = pdfPage.getViewport({ scale: scale * CSS_UNITS, });
|
||||
for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
||||
let textLayerFactory = null;
|
||||
if (this.textLayerMode !== TextLayerMode.DISABLE) {
|
||||
|
@ -1031,7 +1031,7 @@ class BaseViewer {
|
|||
*/
|
||||
getPagesOverview() {
|
||||
let pagesOverview = this._pages.map(function(pageView) {
|
||||
let viewport = pageView.pdfPage.getViewport(1);
|
||||
let viewport = pageView.pdfPage.getViewport({ scale: 1, });
|
||||
return {
|
||||
width: viewport.width,
|
||||
height: viewport.height,
|
||||
|
|
|
@ -48,7 +48,7 @@ function composePage(pdfDocument, pageNumber, size, printContainer) {
|
|||
let renderContext = {
|
||||
canvasContext: ctx,
|
||||
transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
|
||||
viewport: pdfPage.getViewport(1, size.rotation),
|
||||
viewport: pdfPage.getViewport({ scale: 1, rotation: size.rotation, }),
|
||||
intent: 'print',
|
||||
};
|
||||
return pdfPage.render(renderContext).promise;
|
||||
|
|
|
@ -118,8 +118,8 @@ class PDFPageView {
|
|||
this.pdfPageRotate = pdfPage.rotate;
|
||||
|
||||
let totalRotation = (this.rotation + this.pdfPageRotate) % 360;
|
||||
this.viewport = pdfPage.getViewport(this.scale * CSS_UNITS,
|
||||
totalRotation);
|
||||
this.viewport = pdfPage.getViewport({ scale: this.scale * CSS_UNITS,
|
||||
rotation: totalRotation, });
|
||||
this.stats = pdfPage.stats;
|
||||
this.reset();
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
|
|||
let renderContext = {
|
||||
canvasContext: ctx,
|
||||
transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
|
||||
viewport: pdfPage.getViewport(1, size.rotation),
|
||||
viewport: pdfPage.getViewport({ scale: 1, rotation: size.rotation, }),
|
||||
intent: 'print',
|
||||
};
|
||||
return pdfPage.render(renderContext).promise;
|
||||
|
|
|
@ -146,7 +146,7 @@ class PDFThumbnailView {
|
|||
this.pdfPage = pdfPage;
|
||||
this.pdfPageRotate = pdfPage.rotate;
|
||||
let totalRotation = (this.rotation + this.pdfPageRotate) % 360;
|
||||
this.viewport = pdfPage.getViewport(1, totalRotation);
|
||||
this.viewport = pdfPage.getViewport({ scale: 1, rotation: totalRotation, });
|
||||
this.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ class PDFThumbnailViewer {
|
|||
|
||||
pdfDocument.getPage(1).then((firstPage) => {
|
||||
let pagesCount = pdfDocument.numPages;
|
||||
let viewport = firstPage.getViewport(1.0);
|
||||
let viewport = firstPage.getViewport({ scale: 1, });
|
||||
for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
||||
let thumbnail = new PDFThumbnailView({
|
||||
container: this.container,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue