Skip to content

hunghg255/dom-to-images

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo

A library convert html to image

NPM Version NPM Downloads Minizip Contributors License

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>

Releases

No releases published

Packages

No packages published