{"action":"created","issue":{"url":"https://api.github.com/repos/amir20/phantomjs-node/issues/443","repository_url":"https://api.github.com/repos/amir20/phantomjs-node","labels_url":"https://api.github.com/repos/amir20/phantomjs-node/issues/443/labels{/name}","comments_url":"https://api.github.com/repos/amir20/phantomjs-node/issues/443/comments","events_url":"https://api.github.com/repos/amir20/phantomjs-node/issues/443/events","html_url":"https://github.com/amir20/phantomjs-node/issues/443","id":147916608,"number":443,"title":"How to generate pdf file output?","user":{"login":"symonny","id":2889300,"avatar_url":"https://avatars.githubusercontent.com/u/2889300?v=3","gravatar_id":"","url":"https://api.github.com/users/symonny","html_url":"https://github.com/symonny","followers_url":"https://api.github.com/users/symonny/followers","following_url":"https://api.github.com/users/symonny/following{/other_user}","gists_url":"https://api.github.com/users/symonny/gists{/gist_id}","starred_url":"https://api.github.com/users/symonny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symonny/subscriptions","organizations_url":"https://api.github.com/users/symonny/orgs","repos_url":"https://api.github.com/users/symonny/repos","events_url":"https://api.github.com/users/symonny/events{/privacy}","received_events_url":"https://api.github.com/users/symonny/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-13T01:09:28Z","updated_at":"2016-04-13T02:28:14Z","closed_at":"2016-04-13T02:28:14Z","body":"Hey there,\r\n\r\nI have updated to the new version and I'm not sure how to get the pdf filled with a provided html content. Please let me know what should I correct below.\r\nThanks in advance.  \r\n   \r\n    `var createPDF = function(options, html, filePath, callback) {\r\n        var phInstance = null;\r\n        var sitepage = null;\r\n        phantom.create().then(function (ph) {\r\n            phInstance = ph;\r\n            return phInstance.createPage();\r\n        }).then(function(page){\r\n            console.log('page');\r\n            sitepage = page;\r\n            var paperSize = {\r\n                format: 'letter',\r\n                orientation: 'portrait',\r\n                margin: {left: \"1.25cm\", right: \"1.25cm\", top: \"1.25cm\", bottom: \"1.25cm\"}\r\n            };\r\n                page.setting('javascriptEnabled');\r\n                page.property('paperSize', paperSize);\r\n                page.property('viewportSize',  {width: 704, height: 1054}); \r\n                page.property('zoomFactor', 0.9);\r\n                page.property('content', html);\r\n        }).then(function(status){\r\n            console.log(status);\r\n                return sitepage.property('content');\r\n        }).then(function(content){\r\n            console.log(content);\r\n            sitepage.render(filePath, {format: 'pdf', quality: '100'}).then(function(res){\r\n                /* var outObj = phInstance.createOutObject();\r\n                 sitepage.property('onResourceRequested', function(requestData, networkRequest, debug, out) {\r\n                 if(debug){\r\n                 out.url = requestData.url;\r\n                 }\r\n                 }, process.env.DEBUG, outObj);\r\n\r\n                 outObj.property('url').then(function(url){\r\n                 console.log(url);\r\n                 });*/\r\n                setTimeout(function () {\r\n                     sitepage.close();\r\n                     phInstance.exit();\r\n                    return callback(null, filePath);\r\n                }, 25000);\r\n            }).catch(function (err){\r\n                console.log(err);\r\n                sitepage.close();\r\n                phInstance.exit();\r\n            });\r\n\r\n        }).catch(function(err){\r\n            console.log(err);\r\n            phInstance.exit();\r\n        });\r\n    };`"},"comment":{"url":"https://api.github.com/repos/amir20/phantomjs-node/issues/comments/209198533","html_url":"https://github.com/amir20/phantomjs-node/issues/443#issuecomment-209198533","issue_url":"https://api.github.com/repos/amir20/phantomjs-node/issues/443","id":209198533,"user":{"login":"amir20","id":260667,"avatar_url":"https://avatars.githubusercontent.com/u/260667?v=3","gravatar_id":"","url":"https://api.github.com/users/amir20","html_url":"https://github.com/amir20","followers_url":"https://api.github.com/users/amir20/followers","following_url":"https://api.github.com/users/amir20/following{/other_user}","gists_url":"https://api.github.com/users/amir20/gists{/gist_id}","starred_url":"https://api.github.com/users/amir20/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amir20/subscriptions","organizations_url":"https://api.github.com/users/amir20/orgs","repos_url":"https://api.github.com/users/amir20/repos","events_url":"https://api.github.com/users/amir20/events{/privacy}","received_events_url":"https://api.github.com/users/amir20/received_events","type":"User","site_admin":false},"created_at":"2016-04-13T02:28:14Z","updated_at":"2016-04-13T02:28:14Z","body":"That's a lot of code to figure out what you are doing wrong. This is not a bug, so I'll point you the right direction. https://github.com/amir20/phantomjs-node/blob/master/src/spec/page_spec.js#L284 there are some example there you can use. You basically should use `page.setContent`.\r\n\r\nIf you find any bugs, then feel free to open a bug. "}}