javascripthtmlcssimagerender

How to render HTML to an image


Is there a way to render HTML to an image like PNG? I know that it is possible with canvas but I would like to render standard HTML element like div for example.


Solution

  • There is a lot of options and they all have their pro and cons.

    Option 1: Use an API

    Pros

    Cons

    Option 2: Use one of the many available libraries

    Pros

    Cons

    Option 3: Use PhantomJs and maybe a wrapper library

    Pros

    Cons

    Option 4: Use Chrome Headless and maybe a wrapper library

    Pros

    Cons

    Disclosure: I'm the founder of ApiFlash. I did my best to provide an honest and useful answer.