dom-to-images
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

dom-to-images

npm version

Usage

import { toPng, toJpeg, toBlob } from "dom-to-images"

const dataUrl = await toPng(el, options)
const dataUrl = await toJpeg(el, options)
const blob = await toBlob(el, options)

Options

export interface Options {
  filter?: (node: Node) => boolean
  bgcolor?: string
  width?: number
  height?: number
  style?: {}
  quality?: number
  imagePlaceholder?: string
  cacheBust?: boolean
}

Browser Support

<script type="module" src="https://unpkg.com/dom-to-images/dist/index.mjs"></script>

<script>
  DomToImage.toPng(document.body).then(function (dataUrl) {
    const a = document.createElement('a')
    a.download = 'image.png'
    a.href = dataUrl
    a.click()
  })
</script>

Readme

Keywords

none

Package Sidebar

Install

npm i dom-to-images

Weekly Downloads

19

Version

0.0.3

License

MIT

Unpacked Size

5.15 kB

Total Files

6

Last publish

Collaborators

  • hunghg255