easy-dom2img
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

easy-dom2img

a dom-to-image tools writing in typescript, which is powerful and easy to use

code samples

import dom2Img, { AutoFitByRatio } from "easy-dom2img";

const dom =  document.getElementById("resume")

const {
  data: imgUrl,   // result will return as base64 data url
  width,          // the image's width
  height,         // the image's height
} = await dom2Img(dom, {
  width: 1000,              // the rendered image's width you want, default is AutoFitByRatio
  height: AutoFitByRatio,   // the rendered image's width you want, default is AutoFitByRatio
  /* Here are some optional params...

  filter: (node: Node) => { // filter node function which you can filter the dom you dont want to be rendered
    return true
  },

  bgcolor: '#fff',          // the rendered image background color

  placeholder: 'data:XXXX'  // the placeholder image which is base64 data url

  noCache: false            // indicate if the resource request from url using cache or not

  */
})

Package Sidebar

Install

npm i easy-dom2img

Weekly Downloads

2

Version

1.0.2

License

ISC

Unpacked Size

24.2 kB

Total Files

4

Last publish

Collaborators

  • yiuyiuyiu