html轉圖片網頁截屏(一),java庫cssbox


引入依賴包

<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
來源:CSDN
原文:https://blog.csdn.net/qq_36029699/article/details/86507825
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM