1

i need to ask if there are a way ( applet or any think else ) to take a screenshot of the content on a div in webpage ???

i found this java code to take screenshot of the full screen :

import java.awt.AWTException;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class ScreenShot
{
    /**
    method to capture screen shot
    @param String uploadPath to save screen shot as image
    @returns boolean true if capture successful else false
    */
    boolean captureScreenShot(String uploadPath)
    {
        boolean isSuccesful = false;
        Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
        BufferedImage capture;
        try
        {
            capture = new Robot().createScreenCapture(screenRect);
            // screen shot image will be save at given path with name "screen.jpeg"
            ImageIO.write(capture, "jpg", new File( uploadPath, "screen.jpeg"));
            isSuccesful = true;
        }
        catch (AWTException awte)
        {
            awte.printStackTrace();
            isSuccesful = false;
        }
        catch (IOException ioe)
        {
            ioe.printStackTrace();
            isSuccesful = false;
        }
        return isSuccesful;
    }
}

thanks

Jonathan
  • 20,053
  • 6
  • 63
  • 70
haffane hatim
  • 474
  • 5
  • 30

1 Answers1

0

This is similar to the following question: Take a screenshot of a web page in Java

Community
  • 1
  • 1
joey.enfield
  • 1,229
  • 8
  • 14