推荐的node方案(效果更好)
https://www.cnblogs.com/lixiaoran/p/10802573.html
引入依赖包
<dependency>
<groupId>net.sf.cssbox</groupId>
<artifactId>cssbox</artifactId>
<version>4.14</version>
</dependency>
案例:
public static void main(String[] args) throws Exception {
ImageRenderer render = new ImageRenderer();
render.setWindowSize(new Dimension(800, 1000), false);
System.out.println("kaishi");
String url = new File("G:/index.html").toURI().toString();
FileOutputStream out = new FileOutputStream(new File("G:"+ File.separator+"cssbox.png"));
Thread.sleep(10000);
render.renderURL(url, out, ImageRenderer.Type.PNG);
System.out.println("OK");
}
---------------------
作者:青春微凉love
来源:优快云
原文:https://blog.youkuaiyun.com/qq_36029699/article/details/86507825
版权声明:本文为博主原创文章,转载请附上博文链接!
本文介绍使用CSSBox库将HTML页面转换为图片的方法。通过设置窗口大小并指定输出文件路径,可以轻松实现网页快照功能。
2958

被折叠的 条评论
为什么被折叠?



