easy-dom2img
v1.0.2
Published
a easy use dom-to-img tools
Downloads
92
Maintainers
Readme
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
*/
})