From 7888a37a3d683e41523b324591db38561b921625 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Fri, 4 Aug 2017 01:01:10 -0700 Subject: [PATCH] Page.pdf should accept case-insensetive page format (#211) --- lib/Page.js | 22 +++++++++++----------- test/test.js | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/Page.js b/lib/Page.js index 6b9617e8666..1fb0c89b591 100644 --- a/lib/Page.js +++ b/lib/Page.js @@ -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 = { diff --git a/test/test.js b/test/test.js index b03b91dfec8..21591947f96 100644 --- a/test/test.js +++ b/test/test.js @@ -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);