Last active
January 8, 2017 19:17
-
-
Save FarazPatankar/4ae0a4f646678a3d0059975499fc73ea to your computer and use it in GitHub Desktop.
PhantomJS configuration to get the entire chart to render.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var webpage = require('webpage'); | |
| var system = require('system'); | |
| var input = system.args[1]; | |
| var output = system.args[2]; | |
| var page = webpage.create(); | |
| var capture = function (page, input, callback) { | |
| page.open(input, function (status) { | |
| console.log('Page Opened'); | |
| var interval, allDone; | |
| interval = setInterval(function () { | |
| console.log('Waiting...'); | |
| var allDone = page.evaluate(function () { return window.chartReady;}); | |
| if (allDone) { | |
| console.log('Ready!'); | |
| clearInterval(interval); | |
| callback(); | |
| } | |
| }, 100); | |
| }); | |
| }; | |
| capture(page, input, function (err) { | |
| if (err) { | |
| console.log(err); | |
| } else { | |
| page.render(output, {format: 'pdf'}); | |
| } | |
| phantom.exit(); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment