Reputation: 631
when i take screenshots using phanomjs using the following code works fine and I am getting width as 1920px and height is not a problem for me.
var webPage = require('webpage');
var page = webPage.create();
page.viewportSize = { width: 1920, height: 1080 };
page.open("http://www.google.com", function start(status) {
page.render('google_home.png');
phantom.exit();
but, when i set the dimension as
page.viewportSize = { width: 320, height: 780 };
the resulting image width is 602px.
how to set width for taking screenshot using page.render() function?
Upvotes: 0
Views: 1061
Reputation: 61952
If the minimum page width (or fixed width) is bigger than the viewport size, then PhantomJS will render a screenshot that has the same width as the page (body).
You can of course crop the screenshot by setting the corresponding dimension and position using page.clipRect
.
You can also experiment with the zoomFactor
.
Upvotes: 0
Reputation: 631
Actually I can't. because "http://www.google.com" forcefully set the minimum width of the document above some 600px. so, when i call page.render()
it renders the complete document which is having a width not 320px.
Upvotes: 0