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

[api-minor] Add basic support for PageLayout in the API and the viewer

Please see the specification, https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G6.2393749, and refer to the inline comments for additional details.
This commit is contained in:
Jonas Jenwald 2019-04-03 13:48:18 +02:00
parent 57abddc9ca
commit 7a999d1d67
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);
}