我需要在 webview 中获取整个 html 文档的快照,我这样做是这样的:
BorderPane pane = new BorderPane();
browser = new WebView();
webEngine = browser.getEngine();
webEngine.loadContent(_content);
pane.setCenter(browser);
Scene scene = new Scene(pane);
try {
SnapshotParameters params = new SnapshotParameters();
Image image = pane.snapshot(params, null);
File out = new File("c:\\1.png");
ImageIO.write( SwingFXUtils.fromFXImage(image, null) , "png", out);
} catch (IOException e) {
e.printStackTrace();
}
问题是我不知道文档的高度和宽度。