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 };
page.open('https://thecodingstuff.com/', function() {
    page.render('thecodingstuff.png');
    phantom.exit();
});

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s