Search code examples
javahtmljqueryscreenshot

How to generate an image from a snippet of HTML code (as it is interpreted by the browser) on fly at runtime


Can anyone guide how to generate image from input html code by Java API or Jquery library? otherwise, how can I make a screenshot of a snippet of HTML code as it is interpreted by the browser?

for example : if I have this HTML code :

<h1>Logo</h1><img src="http://blog.stackoverflow.com/wp-content/uploads/stackoverflow-logo-300.png">

I will generate an image which includes a screenshot of this code as it's interpreted by the browser


Solution

  • See: rendering html to png (server-side)

    And as you want a Java API, Html2Image is the best solution for you.