diff --git a/lib/webshot.phantom.js b/lib/webshot.phantom.js index 7147cdb..b5ccdcd 100644 --- a/lib/webshot.phantom.js +++ b/lib/webshot.phantom.js @@ -69,6 +69,29 @@ var toOverwrite = optUtils.mergeObjects( optUtils.phantomPage.forEach(function(key) { if (toOverwrite[key]) page[key] = toOverwrite[key]; + if (key === "paperSize" && page[key] && page[key].header && page[key].header.contents) { + var header = { + "height": page[key].header.height, + "contents": phantom.callback(function() { return options.paperSize.header.contents; }) + }; + page.paperSize.header = header; + } + if (key === "paperSize" && page[key] && page[key].footer && page[key].footer.contents) { + var footer = { + "height": page[key].footer.height, + "contents": phantom.callback(function() { return options.paperSize.footer.contents; }) + }; + page[key].footer = footer; + } + if (key === "paperSize") { + page.paperSize = { + "format": options.paperSize.format, + "orientation": options.paperSize.orientation, + "margin": options.paperSize.margin, + "header": header, + "footer": footer + }; + } }); // The function that actually performs the screen rendering