Screenshots with JavaScript. Next generation!
npm install html2canvas-pro
Next generation JavaScript screenshots tool.
html2canvas-pro is a fork of niklasvh/html2canvas that includes various fixes and new features. It offers several advantages over the original html2canvas, such as:
- support color function ``color()` (including relative colors)`
- support color function lab()``
- support color function lch()``
- support color function oklab()``
- support color function oklch()``
- Support object-fit of `
- Fixed some issues
If you found this helpful, don't forget to
leave a star đ.
`sh`
npm install html2canvas-pro
pnpm / yarn add html2canvas-pro
javascript
import html2canvas from 'html2canvas-pro';
`To render an
element with html2canvas-pro with some (optional) options, simply call html2canvas(element, options);$3
`javascript
html2canvas(document.body).then(function(canvas) {
document.body.appendChild(canvas);
});
`$3
â ď¸ Important: By default, the output canvas dimensions are affected by
devicePixelRatio. `javascript
// If you need exact pixel dimensions (e.g., for a specific file size):
html2canvas(element, {
width: 1920,
height: 1080,
scale: 1 // Set scale to 1 for exact dimensions
}).then(canvas => {
// Canvas will be exactly 1920Ă1080 pixels
const dataURL = canvas.toDataURL('image/png');
});
``See the Configuration Guide for more details.
If you want to add some features, feel free to submit PR.
If you want to become a maintainer on it, please contact me.
MIT.