【问题标题】:Applet Java To take a screenshot of a part of my web pageApplet Java 截取我网页的一部分
【发布时间】:2012-11-24 09:30:44
【问题描述】:

我需要询问是否有办法(小程序或其他任何想法)截取网页中 div 上的内容???

我找到了这个java代码来截取全屏:

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;
    }
}

谢谢

【问题讨论】:

  • 截取网页中某个 div 上的内容 - 你能详细说明一下吗?
  • 是的,我有一个 apenlayers 的地图对象,我只需要为地图而不是整页截屏

标签: java jquery html web applet


【解决方案1】:

这类似于以下问题:Take a screenshot of a web page in Java

【讨论】:

    猜你喜欢
    • 2012-03-12
    • 2012-03-12
    • 2010-10-20
    • 1970-01-01
    • 1970-01-01
    • 2012-11-15
    • 2015-09-25
    • 2022-10-14
    • 1970-01-01
    相关资源
    最近更新 更多