3

我需要拍摄一个很长的页面的快照。我想拍摄多张截图并将它们放在一起行李。移动视图我正在使用 javascript 进行滚动。

这些功能:

private ArrayList<BufferedImage> takeSnapshots (int numRows, int numCols){
     ArrayList<BufferedImage> snapshotsList = new ArrayList ();
    for (int i=0; i<numRows; i++){
        for (int j=0; j<numCols; j++){
            forward ((BASE_WIDTH*j), (BASE_HEIGHT*i));
            WritableImage snapshot = webView.snapshot(null, null);
            snapshotsList .add (SwingFXUtils.fromFXImage(snapshot , null));
        }
    }
    return snapshotsList ;
}

private void  forward (int widht, int height ){
    webEngine.setJavaScriptEnabled(true);
    webEngine.executeScript("window.scrollTo(" + widht+ ", " + height + ")");
}

此代码向我返回第一个块的屏幕截图列表,最后进行滚动。有什么想法可以解决吗?

4

0 回答 0