hkirk / java-html2image

Automatically exported from code.google.com/p/java-html2image
136 stars 68 forks source link

java-html2image

Automatically exported from code.google.com/p/java-html2image

Html2Image

This simple Java library converts plain HTML markup to image and provides client-side image-map using HTML element.

What Can I Do With It: Use Cases

What Do I Give and What Do I Get

Html2Image allows you to transform this HTML markup:

<b>Hello World!</b> Please goto <a title="Goto Google" href="http://www.google.com">Google</a>.

To this visually equivalent HTML markup:

<map name="map">
<area href="http://www.google.com" coords="153,3,193,22" shape="rect" title="Goto Google">
</map>
<img border="0" usemap="#map" src="https://github.com/hkirk/java-html2image/raw/master/hello-world.png"/>

Supported Images Formats Html2Image allows you to save your HTML as GIF, PNG or JPEG image.

API Html2Image as only one useful Java class, HtmlImageGenerator.

Common usage is this:

HtmlImageGenerator imageGenerator = new HtmlImageGenerator(); imageGenerator.loadHtml("Hello World! Please goto <a title=\"Goto Google\" href=\"http://www.google.com\">Google."); imageGenerator.saveAsImage("hello-world.png"); imageGenerator.saveAsHtmlWithMap("hello-world.html", "hello-world.png"); Which will generate hello-world.png image of the HTML and hello-world.html file containing client-side image-map (as in the example above).

HtmlImageGenerator Methods

Download

You can download Html2Image from the download page or use it as Maven dependency:

<dependency>
   <groupId>gui.ava</groupId>
   <artifactId>html2image</artifactId>
   <version>0.9</version>
</dependency>

<repositories>
   <repository>
      <id>yoava</id>
      <name>AOL yoava</name>
      <url>http://yoava.artifactoryonline.com/yoava/repo</url>
   </repository>
</repositories>

License: GNU Lesser GPL