1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #10709 from Snuffleupagus/pageLayout

[api-minor] Add basic support for PageLayout in the API and the viewer
This commit is contained in:
Tim van der Meij 2019-04-05 23:07:32 +02:00 committed by GitHub
commit b161050df4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 85 additions and 2 deletions

View file

@ -376,6 +376,27 @@ class Catalog {
return pageLabels;
}
get pageLayout() {
const obj = this.catDict.get('PageLayout');
// Purposely use a non-standard default value, rather than 'SinglePage', to
// allow differentiating between `undefined` and /SinglePage since that does
// affect the Scroll mode (continuous/non-continuous) used in Adobe Reader.
let pageLayout = '';
if (isName(obj)) {
switch (obj.name) {
case 'SinglePage':
case 'OneColumn':
case 'TwoColumnLeft':
case 'TwoColumnRight':
case 'TwoPageLeft':
case 'TwoPageRight':
pageLayout = obj.name;
}
}
return shadow(this, 'pageLayout', pageLayout);
}
get pageMode() {
const obj = this.catDict.get('PageMode');
let pageMode = 'UseNone'; // Default value.

View file

@ -517,6 +517,10 @@ var WorkerMessageHandler = {
}
);
handler.on('GetPageLayout', function wphSetupGetPageLayout(data) {
return pdfManager.ensureCatalog('pageLayout');
});
handler.on('GetPageMode', function wphSetupGetPageMode(data) {
return pdfManager.ensureCatalog('pageMode');
});

View file

@ -657,6 +657,14 @@ class PDFDocumentProxy {
return this._transport.getPageLabels();
}
/**
* @return {Promise} A promise that is resolved with a {string} containing
* the page layout name.
*/
getPageLayout() {
return this._transport.getPageLayout();
}
/**
* @return {Promise} A promise that is resolved with a {string} containing
* the page mode name.
@ -2214,6 +2222,10 @@ class WorkerTransport {
return this.messageHandler.sendWithPromise('GetPageLabels', null);
}
getPageLayout() {
return this.messageHandler.sendWithPromise('GetPageLayout', null);
}
getPageMode() {
return this.messageHandler.sendWithPromise('GetPageMode', null);
}