html-as
html-as
is a simple npm module that provides a function for asynchronously converting the content of an HTML element to an image and initiating the download. It uses the popular html2canvas
library under the hood.
Installation
npm install html-as
Usage
import { downloadHtmlAsImage } from 'html-as';
const downloadHtmlElementAsImage = async () => {
const element = document.body;
await downloadHtmlAsImage(element, 'body_image', 'jpeg', 2);
}
Error Handling
Any errors that occur during the process are logged to the console.
Dependencies
html2canvas
License
This project is licensed under the MIT License - see the LICENSE file for details.