Screen capture using JAVASCRIPT PhantomJs

Screen capture using JAVASCRIPT PhantomJs

How we can capture the screen of the website to specific┬áposition and size using JAVASCRIPT. Let’s see we can capture screen and store it as an Image file using PhantomJs.

First of all, Download PhantomJs form here.

After, download PhantomJs create the new javascript file screencapture.js Then past the below content.

var page = require('webpage').create();
page.viewportSize = { width: 1300, height: 2000 };
page.clipRect = { top: 0, left: 0, width: 1300, height: 2000 };'', function() {

Now, change the page URL as you want for capture screen.

Change the Image height and width as you want Also, you can set the image position as you want.

After past, that code run the js file like below.

phantomjs.exe screencapture.js

After, complete find “thecodingstuff.png” file on your directory.

If you face any issue after using above command write the comment below.