Tools to Capture and Convert the Web

Advanced Screenshot Features with Java

Java API

In addition to the basic screenshot functionality GrabzIt's Java API enables the status of existing screenshots to be checked and the allows the cookies that should be used when GrabzIt creates a capture to be customized.

Screenshot Status

Occasionally an app may need to check the status of a screenshot, perhaps to see if it has been taken or to check if it is still cached.

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

Status status = grabzIt.GetStatus(screenShotId);

if (status.isProcessing())
{
    // screenshot has not yet been processed
}

if (status.isCached())
{
    // screenshot is still cached by GrabzIt
}

if (status.isExpired())
{
    // screenshot is no longer on GrabzIt
    // Perhaps output status message?
}

Cookies

Often websites use cookies to control functionality, such as determining if a user is signed in. Using the below cookie methods you can set your own custom cookies.

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

// gets an array of cookies for google.com
Cookie[] cookies = grabzIt.Cookies("google.com");

// sets a cookie for the google.com domain
grabzIt.SetCookie("MyCookie", "google.com", "Any Value You Like");

// deletes the previously set cookie
grabzIt.DeleteCookie("MyCookie", "google.com");

The above delete cookie method will delete all of your cookies stored on GrabzIt with the same name and domain.

Display a Capture without Downloading

While its recommended a capture is downloaded to a web server before being used. It is possible to display any type of capture in a user's browser without downloading it onto your web server first.

Once the capture has completed you can send the bytes of the capture returned by the SaveTo method to the response along with the correct mime type.

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

grabzIt.URLToImage("https://www.tesla.com");
GrabzItFile capture = grabzIt.SaveTo();

if (capture != null)
{ 
    String mimeType = "image/jpeg";
    capture.getBytes();
}

In the example above we get the bytes of the capture and the MIME type but how it is returned to the response will depend on the framework you are using.