Java Html2image implements HTML-to-picture functionality
Html2image
Htmlimagegenerator imagegenerator = new Htmlimagegenerator ();
String htmlstr = "<table width= ' 654 ' cellpadding= ' 0 ' cellspacing= ' 0 ' bordercolor= ' #FFFFFF ' ><tr ><td></td><td></td ><td></td></tr><tr ><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td>≪/tr><tr><td></td> </tr></table> ";
Imagegenerator.loadhtml (HTMLSTR);
Imagegenerator.getbufferedimage ();
Imagegenerator.saveasimage ("D:/hello-world.png");
Imagegenerator.saveashtmlwithmap ("hello-world.html", "hello-world.png");
Html2image API Introduction
Htmlimagegenerator Methods
- loadurl (URL) -Loads HTML from URL object or URL string. (loading HTML from URL)
- loadhtml (html) -Loads HTML source. (load local HTML)
- saveasimage (file) -Save loaded HTML as image. (Save HTML as a picture)
- Saveashtmlwithmap (file, imageUrl) -Creates an HTML file containing client-side image-map <map>generated from HTML ' s links. (Create an HTML file that contains the client Image-map)
- getlinks () -List all links in the HTML document and their corresponding href, target, title, position and Dimens Ion. (List all links and corresponding href, target, title, location, and size in the HTML document)
- getbufferedimage () -Get AWT buffered image of the HTML. (Get the picture after awt,html buffer)
- Getlinksmapmarkup (mapName) -Get HTML snippet of the client-side image-map <map> generated F Rom the links. (Client Image-map < maps > generated links obtained in HTML snippet)
- get/setorientation (orientation) -get/set document orientation (left-to-right or right-to-left). (Get/set text positioning)
- get/setsize (dimension) -Get/set size of the generated image. (Set build picture size)
Java Html2image implements HTML-to-picture functionality