Java Html2image implements HTML-to-picture functionality

Source: Internet
Author: User

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>&Lt;/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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.