Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Div or html to image (alternative to html2canvas) [closed]

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!!!

like image 313
Car Lautaro Avatar asked May 03 '17 09:05

Car Lautaro


People also ask

What is html2canvas?

html2canvas is a JavaScript library that enables users to produce screenshots of an entire webpage or portions of a webpage. The screenshots are taken directly on the user's browser. Technically, html2canvas does not actually take a screenshot, rather it creates a view based on the data that is present on the page.


2 Answers

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.

like image 194
Abhishek K Avatar answered Sep 22 '22 20:09

Abhishek K


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.

like image 31
Frank Guo Avatar answered Sep 23 '22 20:09

Frank Guo