Reputation: 602
I'm trying to render html
to jpg
using phantomjs.
Phantom renders stack overflow site perfectly, but doesn't render my own html page (which shows pieChart, generated by js).
here is phantom script:
var webPage = require('webpage');
var system = require('system');
var page = webPage.create();
page.viewportSize = { width: 1920, height: 1080 };
page.open(system.args[1], function start(status) {
page.render('index.jpeg', {format: 'jpeg', quality: '100'});
phantom.exit();
});
And here is output img:
How to fix rendering?
Upvotes: 0
Views: 128
Reputation: 16838
The chart is probably not shown in the image because the screenshot is made immediately after page is opened. Try to postpone making a screenshot for a second like this:
page.open(system.args[1], function start(status) {
setTimeout(function(){
page.render('index.jpeg', {format: 'jpeg', quality: '100'});
phantom.exit();
}, 1000);
});
Upvotes: 1