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!!!
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With