{"action":"opened","issue":{"url":"https://api.github.com/repos/segmentio/nightmare/issues/943","repository_url":"https://api.github.com/repos/segmentio/nightmare","labels_url":"https://api.github.com/repos/segmentio/nightmare/issues/943/labels{/name}","comments_url":"https://api.github.com/repos/segmentio/nightmare/issues/943/comments","events_url":"https://api.github.com/repos/segmentio/nightmare/issues/943/events","html_url":"https://github.com/segmentio/nightmare/issues/943","id":198636541,"number":943,"title":"Extra page in PDF generation with custom page sizes","user":{"login":"Mins","id":1380839,"avatar_url":"https://avatars.githubusercontent.com/u/1380839?v=3","gravatar_id":"","url":"https://api.github.com/users/Mins","html_url":"https://github.com/Mins","followers_url":"https://api.github.com/users/Mins/followers","following_url":"https://api.github.com/users/Mins/following{/other_user}","gists_url":"https://api.github.com/users/Mins/gists{/gist_id}","starred_url":"https://api.github.com/users/Mins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mins/subscriptions","organizations_url":"https://api.github.com/users/Mins/orgs","repos_url":"https://api.github.com/users/Mins/repos","events_url":"https://api.github.com/users/Mins/events{/privacy}","received_events_url":"https://api.github.com/users/Mins/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-01-04T06:11:29Z","updated_at":"2017-01-04T06:11:29Z","closed_at":null,"body":"Most probably due to Electron but when rendering fullpage PDF using the pageSize option, 2 pages are rendered in the PDF instead of just 1.\r\n\r\nThe code below does the following\r\n  - Load a page\r\n  - Get the page width and height\r\n  - Convert sizes to micron meters\r\n  - Resize the viewport\r\n  - Render full page PDF\r\n\r\n```\r\nvar Nightmare = require('nightmare');\r\nvar nightmare = Nightmare({ show: false, width: 1980, maxWidth:100000, maxHeight:100000 });\r\n\r\nvar calcSize = function(width, height) {\r\n  // Size in micronmeters\r\n  return { pageSize: { height: Math.ceil(height * 254/96*100), width: Math.ceil(width * 254/96*100) }, marginsType: 1 };\r\n};\r\n\r\nnightmare\r\n  .goto('https://facebook.com')\r\n  .wait(3000)\r\n  .evaluate(function () {\r\n    var body = document.body, html = document.documentElement;\r\n    var height = Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight );\r\n    var width = Math.max( body.scrollWidth, body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth );\r\n    return { width: width, height: height };\r\n  })\r\n  .then( function (result) {\r\n    var size = calcSize(result.width, result.height)\r\n    nightmare.viewport(result.width, result.height).wait(1000).pdf(\"./screenshot.pdf\", size).end().then();\r\n  })\r\n```\r\n\r\nWhile it happens with facebook.com, no issues are seen when rendering github.com. Looking at the problematic PDFs, I noticed that the last few pixels of the full page is rendered on the second page."}}
{"actor":{"display_login":"Mins"}}