Page.pdf should accept case-insensetive page format (#211)

This commit is contained in:
Andrey Lushnikov 2017-08-04 01:01:10 -07:00 committed by GitHub
parent 00196e6cdc
commit 7888a37a3d
2 changed files with 12 additions and 12 deletions

View File

@ -470,7 +470,7 @@ class Page extends EventEmitter {
let paperWidth = 8.5;
let paperHeight = 11;
if (options.format) {
let format = Page.PaperFormats[options.format];
let format = Page.PaperFormats[options.format.toLowerCase()];
console.assert(format, 'Unknown paper format: ' + options.format);
paperWidth = format.width;
paperHeight = format.height;
@ -627,16 +627,16 @@ class Page extends EventEmitter {
/** @enum {string} */
Page.PaperFormats = {
Letter: {width: 8.5, height: 11},
Legal: {width: 8.5, height: 14},
Tabloid: {width: 11, height: 17},
Ledger: {width: 17, height: 11},
A0: {width: 33.1, height: 46.8 },
A1: {width: 23.4, height: 33.1 },
A2: {width: 16.5, height: 23.4 },
A3: {width: 11.7, height: 16.5 },
A4: {width: 8.27, height: 11.7 },
A5: {width: 5.83, height: 8.27 },
letter: {width: 8.5, height: 11},
legal: {width: 8.5, height: 14},
tabloid: {width: 11, height: 17},
ledger: {width: 17, height: 11},
a0: {width: 33.1, height: 46.8 },
a1: {width: 23.4, height: 33.1 },
a2: {width: 16.5, height: 23.4 },
a3: {width: 11.7, height: 16.5 },
a4: {width: 8.27, height: 11.7 },
a5: {width: 5.83, height: 8.27 },
};
let unitToPixels = {

View File

@ -1407,7 +1407,7 @@ describe('Page', function() {
}));
it('should support setting custom format', SX(async function() {
let pages = await getPDFPages(await page.pdf({
format: 'A4'
format: 'a4'
}));
expect(pages.length).toBe(1);
expect(pages[0].width).toBeCloseTo(8.27, 1);