Generate a screenshot of the page with javascript
Install:
npm install html2screenshot
The html2screenshot library utilizes Promises and expects them to be available in the global context.
// html2screenshot(html, options, cb)
html2screenshot(document.body, {
startX: 0,
startY: 0,
canvasW: 100,
canvasH: 200,
background: '#fff',
imageType: 'png',
imageQuality: 1.0
}, (imgUrl) => {
// todo
});
html
element you wanna screenshot.
options
of screenshot.
callback
function, built-in parameters imgUrl
.
startX
of the element you wanna screenshot, default 0.
startY
of the element you wanna screenshot, default 0.
canvasW
is the width of screenshot.
canvasH
is the height of screenshot.
background
of screenshot, default '#fff'.
The type of screenshot, default 'png'.
The quality of screenshot, default 1.0.