html-as

1.0.2 • Public • Published

html-as

npm version

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';

// Defining an asynchronous function to download an HTML element as an image.

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.

Package Sidebar

Install

npm i html-as

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

3.98 kB

Total Files

3

Last publish

Collaborators

  • jascriptor