nir
nir

Reputation: 83

Taking screen shot of webpage in php

I am using following function to take screenshot of a webpage.

function my2()
{

    $Browser = new COM('InternetExplorer.Application');

    $Browserhandle = $Browser->HWND;

    $Browser->Visible = true;
    $Browser->Fullscreen = true;
    $Browser->Navigate('http://www.tatvic.com');

    while ($Browser->Busy)
    {
        com_message_pump(4000);
    }

    $img = imagegrabwindow($Browserhandle, 0);
    $Browser->Quit();
    imagepng($img, 'screenshot.png');
}

This works fine. But as it is a screen shot, it is not taking the whole page. I mean it is not taking the parts of page which we can see by scrolling .

What i can do so the script first zoom out the page to 25% or 35% or converting it to a4 size and then take the screen shot so that image of whole page can be stored ??? .

Thank you.

Upvotes: 1

Views: 706

Answers (1)

Mike Mackintosh
Mike Mackintosh

Reputation: 14237

Take a look at PhantomJS. It is a headlesss WebKit API with JavaScript support. This means, you do not need a GUI/Browser to view.

It allows you to grab the full page, save to PNG, SVG, etc.

Upvotes: 1

Related Questions