6

I did my homework and search several times how to make a "screenshot" of a div or any element on html.

html2canvas works nice but I have problems with: - The quality of the image generated. - If the div have images stored on other domains. - Some elements like rounded divs (inside de main div) are generated squared.

Is there any alternative? Don't discard paid alternatives.

Thanks!!!

Car Lautaro
  • 143
  • 1
  • 1
  • 6

4 Answers4

9

See if this DOM-to-Image works for you - https://github.com/tsayen/dom-to-image

It's a library written in JavaScript which can turn arbitrary DOM node into a vector (SVG) or raster (PNG or JPEG) image.

Abhishek K
  • 161
  • 2
  • 8
2

You could look into http://phantomjs.org/, specifically the https://github.com/ariya/phantomjs/blob/master/examples/rasterize.js example where you are able to save HTML to an image or PDF - effectively creating a screenshot. It is very customisable and I have used this to create PDFs from lists of URLs with ease. It is a server side solution, so would need a little more setup your end.

Luke P
  • 658
  • 4
  • 19
1

I've used both html2canvas and dom-to-image, they both works well, but it seems that dom-to-image works better with images and has better predictability.

FRANK GO
  • 11
  • 1
0

rasterizeHTML.js renders HTML into the browser's canvas

https://cburgmer.github.io/rasterizeHTML.js/

Vitalicus
  • 619
  • 5
  • 14