Question

For our web application we need a feature, where the web application generates image, out of the currently displayed application page.

In detail, it is a java web application where Super user checks the data saved by normal user and convey his remarks to the normal user. For this purpose the super user opens the form where the data is entered by the normal user and click on the button on the same form which should take the screenshot of the displayed form(or should generate image out of the current window html) and save the image on the server.

Is it possible to do it within the webapplication? If yes, please send me the link or example.

Best Regards

Was it helpful?

Solution

give it a try

package hussi.screenshot;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.File;


public class Screenshot
{
    public static void main(String[] args) 
    {
        Screenshot obj = new Screenshot();
        try{
        obj.captureScreen("HussiScreenshot.png");
        }
        catch(Exception e)
        {
            System.out.println(e);
        }

    }


    public void captureScreen(String fileName) throws Exception 
    {

       Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
       Rectangle screenRectangle = new Rectangle(screenSize);
       Robot robot = new Robot();
       BufferedImage image = robot.createScreenCapture(screenRectangle);
       ImageIO.write(image, "png", new File(fileName));

    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top